Need help with this code

Need help with this code
0

#1

I am only outputting the letter “o” but no error message. Need help please:

var str = “hello”;
function reverseString(str) {

str2 = str.split("").reverse("");

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

return str2[i];
}
}

reverseString(“hello”);


#2

First, move the str variable inside the function. Challenges don’t pass if you used global variables.


#3

return stops the function it is in to return the value, even if it’s in the middle of a loop.

Rethink what you are returning and when to do it.


#4

I moved the var declaration inside the function but still outputting “o.” I will appreciate just a clue where to place the “return” so it doesn’t stop at “o.”


#5

Oh well, I am getting closer but still some issues. I able to reverse but I am getting ( “o l, l, e, h”). Also, I need to remove the commas:

function reverseString(str) {
var str2 = “hello”;
str2 = str.split("").reverse("").join();

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

return str2;
}
}

reverseString(“hello”);


#6

Sorry just solved it! I guess I am too impatient.