Run

Reverse a string in JavaScript

Split a string into characters, reverse them and join them back. Press Run to try it, then change the code and run it again.

main.js

function reverse(text) {
  return [...text].reverse().join("");
}

console.log(reverse("CodingHumans")); // snamuHgnidoC
Output

Press Run to see the output.

More JavaScript examples

Open the full JavaScript online compiler →