Basic Algorithm Scripting: Reverse a String - code check

Tell us what’s happening:
Why my code is not accepting?
I checked in Codepen console, all prints out correctly.

Your code so far

function reverseString(str) {
  
 var splits = str.split('');
  console.log(splits);
  var reversed = splits.reverse();
  console.log(reversed);
  console.log(reversed.join(''));
  
  return str;
}

reverseString("hello");

Your browser information:

User Agent is: Mozilla/5.0 (Windows Home 10.0; Win64; x64) Chrome/75.0.3770.80.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/reverse-a-string

Hi @crlybrcs!

I can’t see that you’re returning the new reversed string at the end of the function? I think you’re just returning the passed parameter str which is not what the test is expecting :slightly_smiling_face:.

1 Like