function reverseString(str) {
let newString = "";
for (i = str.length -1; i >= 0; i--) {
newString += str[i];
}
return newString;
}
reverseString("hello");
The above code returned the expected result on the console, but failed to run here. Please help me figure out my issue. The error returned is that i is not defined. Kindly find the screenshot. Thanks.