Ad
Code
Diff
  • // const reverseStr = str => [...str].reverse().join('');   <-- weak smh
    
    function reverseStr(str){return str.split("").reverse().join("")}
    
    console.log(reverseStr('hello world'));
    • // const reverseStr = str => [...str].reverse().join(''); <-- weak smh
    • function reverseStr(str)
    • {
    • let reversedstr = '';
    • stringArr = str.split('');
    • stringArr.forEach(function(char, index) {
    • reversedstr = char + reversedstr;
    • })
    • return reversedstr;
    • }
    • function reverseStr(str){return str.split("").reverse().join("")}
    • console.log(reverseStr('hello world'));