Basic Algorithm Scripting - Reverse a String

Tell us what’s happening:
Describe your issue in detail here.

So I’m trying to reverse this string by first doing a loop but when I check the result in console I keep getting an empty array.

Anyone know why this is?

  **Your code so far**
function reverseString(str) {
let arr = [];
for (let i = (str.length - 1); i <= 0; i-- ){
return arr;

  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Basic Algorithm Scripting - Reverse a String

Link to the challenge:

I don’t think this condition is what you want.

In addition to the above, your function is returning array right now, you need to return a string here.

1 Like

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