Ad
Fundamentals
Strings

For the provided string, reverse the order of its' characters;

Examples:

  • abc becomes cba
  • Hello World! becomes !dlroW olleH
Code
Diff
  • const reverseStr = s => {
      let ss = "";
      for (let i = s.length-1; i >= 0; i--) {
        ss += s[i];
      }
      return ss;
    }
    
    console.log(reverseStr("Lorem ipsum dolor sit amet!"))
    • const reverseStr = s => [...s].reverse().join("")
    • const reverseStr = s => {
    • let ss = "";
    • for (let i = s.length-1; i >= 0; i--) {
    • ss += s[i];
    • }
    • return ss;
    • }
    • console.log(reverseStr("Lorem ipsum dolor sit amet!"))