I am trying to reverse a string but I will get a value as follows when i console.log in chrome console:
function reverseString(str) {
let newString = "";
for (let i = str.length; i + 1 > 0; i--) {
newString = newString + str[i];
}
return (newString);
}
console.log(reverseString("hello there"));
Why is there undefined in front of the reverse string?