How to reverse a string?

How to reverse a string?
0

#1

Why doesn’t it work?


function reverseString(str) {
  
  str.split('').reverse().join('');
  
  return str;
}

reverseString("hello");


#2

You are creating a new string (by creating a new array, reversing it, and joining it) but you aren’t saving that new string. You aren’t assigning it to anything.