Skip to content
WANCODE
BM

Reverse a String

10 minBeginnerAlgorithms

Write a function that takes a string and returns a new string with the characters in reverse order.

JavaScript
reverseString("hello")          // "olleh"
reverseString("Selamat pagi!")  // "!igap tamaleS"
reverseString("")               // ""
reverseString("Saya 🍜")        // "🍜 ayaS"

Examples

Constraints

  • Always return a string (not an array).
  • Spaces and punctuation are characters too — keep them.
  • Single emoji like 🍜 or 👍 must come out unbroken. (Combined emoji such as family or flag emoji are out of scope.)
  • The checker calls your function directly with several inputs. The live demo on the page is just for you.

Implement reverseString(text) in script.js so it returns the characters of text in reverse order — including empty strings and emoji.

Checks

  • Reverses ordinary words
  • Handles empty and one-character strings
  • Keeps emoji intact
Preview

Console output from your code appears here.

Step 1 of 1