This is my code so far for this challenge https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/reverse-a-string.
I tried the same block of code below on the MDN site https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split but added
console.log(reverseString("hello"));
to the end and it correctly displayed “olleh”. Any suggestions?
function reverseString(str) {
var newStr= "";
var wordSplit = str.split('');
var wordRev = wordSplit.reverse();
for (i=0; i<str.length; i++) {
newStr = newStr + wordRev.shift();
}
return newStr;
}