Tell us what’s happening:
I got the code to work and just wanted to know is this an efficient way of using the unshift method vs using the reverse method?
Your code so far
function reverseString(str) {
str.split();
let update = []
for (let i = 0; i < str.length; i++){
update.unshift(str[i])
console.log(update)
}
return update.join("");
}
console.log(reverseString("hello"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
.
Challenge: Reverse a String
Link to the challenge: