Tell us what’s happening:
Getting the following response:-
reverseString("hello")
should return a string.
reverseString("hello")
should become
"olleh"
.
reverseString("Howdy")
should become
"ydwoH"
.
reverseString("Greetings from Earth")
should return
"htraE morf sgniteerG"
. // tests completed // console output htraE morf sgniteerG
Since my output is accurate, why am i still getting arror messages?
Your code so far
function reverseString(str) {
"use strict";
const x = [...str];
var y = [];
for ( var i=(str.length-1); i>=0; i--)
{
y.push(x[i]);
}
return reverseString = y.join('');
}
console.log(reverseString("Greetings from Earth"));
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:77.0) Gecko/20100101 Firefox/77.0
.
Challenge: Reverse a String
Link to the challenge: