I feel like the code is too verbose for this problem, can't we just do
function reverseWords(s) {
const arr = s.split(" ")
let res = []
for (let i = 0; i < arr.length; i++) {
res.push(arr[(arr.length-1)-i])
}
return res.join(" ")
}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I feel like the code is too verbose for this problem, can't we just do
function reverseWords(s) {
const arr = s.split(" ")
let res = []
for (let i = 0; i < arr.length; i++) {
res.push(arr[(arr.length-1)-i])
}
return res.join(" ")
}