Reverse a String - Code not perfect

Tell us what’s happening:
Hey, please let me know how to write this more eloquently and foremost, pass the challenge.

Your code so far

function reverseString(str) {
let arr=[];
for (let i=0; i>str.length; i++) {
let reversed = arr.toString();
return reversed;


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:

I suggest putting a console.log statement like below on the line before your return statement. This will allow you to look at the browser’s console (Ctrl+Shft+J in Chrome) and see exactly what you are returning. Then, you will have a better idea of how to correct your code.


HINT: To start with, your for loop never executes any code inside, because your for loop condition is false from the beginning. Also, str.i will be undefined, because there is no property named “i” in an array. You might want to review previous lessons on how to access values from arrays before continuing with this challenge.

1 Like

Unfortunately I only get “undefined”, and I don’t know what to make of that…

See my edited reply above for a HINT.

1 Like