Reverse a string- problem with joining an array

Reverse a string- problem with joining an array
0.0 0

#1

My code:

function reverseString(str) {
var arr=[];
  
  for(var i=0;i<str.length;i++)
    {
  arr[i]=str[str.length-1-i];
      }
  arr.join('');
  return arr;
}

I wonder why when I do the arr.join, I still get the separated array and not the connected word. I know its possible to do with str.split("").reverse().join("").
Thanks!


#2

you are returning a array … return a string like so
var result = arr.join
return result