Function reverseString(str)

function reverseString(str) {

let convertion

for (let i = 0; i < str.length; i++) {

str.shift()

convertion.push(str.shift());

}

return convertion;

}

reverseString(“hello”);

console.log(reverseString(“hello”));

something is wrong, str.shift is not a function

That’s because shift is only defined on arrays, not strings.

thanks for your advise.

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