Reverse a String - Can't understand what is wrong with my code

I tried:

var reverseString = function(str) {
  var myArray = str;
  var reversed = myArray.reverse();
  return reversed;
};

reverseString("hello");

and

 function reverseString(str) {
   var myArray = str;
   var reversed = myArray.reverse();
   return reversed;
 } 
 reverseString("hello");

The result is the same: “myArray.reverse isn’t a function”.

I searched on Google and I know we can put two vars in the same function and I also checked on developer.mozilla.org the “var reversed” is correct.

Link to the challenge:

reverse is an array method. str is a string. You’ll have to figure out how to convert the string to an array.

1 Like