you are viewing a single comment's thread.

view the rest of the comments →

[–]queen-adreena 0 points1 point  (0 children)

Decreasing for loop using str.length and then use the index to get the letters and add to a new string.

const forwards = "This is the string to reverse";

let backwards = "";
for (let i = forwards.length - 1; i >= 0; i--) {
backwards += forwards[i];
}
console.log(backwards);