Ad

The function should return a reversed string.

you can use built in methods like split() and join().

HINTS:
store the split string in an array.

Code
Diff
  • // const reverseStr = str => [...str].reverse().join('');   <-- weak smh
    
    function reverseStr(str)
    {
      let stringArr;
      let joined;
      
      stringArr = str.split('');
      stringArr.reverse();
      
      joined = stringArr.join('');
      
      return joined;
    }
    
    console.log(reverseStr('hello world'));
    • const reverseStr = str => [...str].reverse().join('');
    • // const reverseStr = str => [...str].reverse().join(''); <-- weak smh
    • function reverseStr(str)
    • {
    • let stringArr;
    • let joined;
    • stringArr = str.split('');
    • stringArr.reverse();
    • joined = stringArr.join('');
    • return joined;
    • }
    • console.log(reverseStr('hello world'));