Reverse a String - I don't see what's wrong

Tell us what’s happening:
I know my solution is quite longer than the suggested ones in the hints provided, but it’s what I came up with and I feel like it should nonetheless pass the tests, and it doesn’t, I’m a bit confused. When I try to see my results with console.log it is what is expected (‘olleh’ for ‘hello’, for example). In the meantime, I will probably try to solve it some other way, but can you help me see why it’s not passing the tests?
Thanks in advance

  **Your code so far**

function reverseString(str) {
let newStr = " ";
let newArr = [];
for (let i=0; i<str.length; i++) {

for (let j=0; j<newArr.length; j++) {
  if (newArr[j] !== undefined) {
    newStr = newStr + newArr[j];

return newStr;


Challenge: Reverse a String

Link to the challenge:

Because there is a white space in the beginning of newStr as you define it like that:

let newStr = " "; 

instead make it:

let newStr = "";

Thank you so much, Mohamed!!
It was such a small detail and I wasn’t seeing it :woman_facepalming:t4:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.