Reverse a String Basic Algo

Tell us what’s happening:
Can’t understand where I’m going wrong.
Your code so far

function reverseString(str) {
  let h = '';
  for(let i = 0; i < str.length; i++){
    h = h + str[length - 1 -i];
  return h;


Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.79 Safari/537.36.

Link to the challenge:

length is not a defined variable anywhere in your code.

1 Like