Reverse a String not passing

This is my code so far for this challenge

I tried the same block of code below on the MDN site but added


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;

Very very very TEENY tiny problem. I opened the console (on most browsers, the F12 key or Developer Tools), and there’s the problem.

Take a look in your for loop - you have

for (i=0; i<str.length; i++){

and, given that the tests are running javascript’s strict mode (I think), that’s giving you an error. It is saying that i is undefined. You’ve assigned it, but you’re missing one TEENY TINY word before the i=0 in that for loop’s opening statement…

@snowmonkey Thank you for seeing that! Totally missed it. Works now.

Easy one to slip past, but the console is your friend. Have you played with it much as yet?

@snowmonkey I have not. Really just took a peek when the actual site was down yesterday after I saw the thread here that reproduced the issue and included screen shots of what was going on from the console I believe. Definitely will going forward.

1 Like