Reverse a String -- should pass?


It DOES do that

look at the output.

So why is that code showing as doing what it’s supposed to in a code pad but not passing?

  **Your code so far**

function reverseString(str) {

let reversed = [];

for (let i = (str.length - 1); i >= 0; i--) {

str = reversed.toString();

return str;

  **Your browser information:**

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0

Challenge: Reverse a String

Link to the challenge:

Where are those commas coming from?

Calling toString() on an array.


You are using the default toString method. See if you can research how to convert an array to a string in JS. There is a way that gives you more control.


thanks. I appreciate that

Nailed it!

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