Tell us what’s happening:
I’ve been through the exercise and have tested it in my console and the output seems almost right. I get the reverse of the string, although the console does also show an ‘undefined’ below the reversed string ‘final’. I’m not sure why this is.
On the FCC console, it says ‘newArray is not defined’. Where is my error?
Your code so far
function reverseString(str) {
newArray = []
arr = str.split("");
for (var i = arr.length; i > -1 ;i--) {
newArray.push(arr[i]);
}
final = newArray.join('');
return final
}
console.log(reverseString("Howdy"));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.75 Safari/537.36.
Link to the challenge: