I think its fine but its not

Tell us what’s happening:

made reverse string its also working fine like hello or howdy is reversed but why is undefined showing before my answer and not working

Your code so far

function reverseString(str) {
var reverse="";
for (var i =str.length; i >= 0;i--)
 reverse +=str[i]
return reverse;


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36.

Challenge: Reverse a String

Link to the challenge:

str.length for “howdy” is 5, because there are 5 characters, but “y” is in the 4th index of the array. That is, “howdy”[4] = “y”, because arrays start at 0. “howdy”[5] is not part of the array, therefore it’s undefined.