Looked around and could not find an answer for this one.
I am trying to reverse each word of a string without changing the order of the words...
this is the code I have:
function wordsReverser(string){
return string.split('').reverse().join('');
}
console.log(wordsReverser('New string, same results.'));
what I am getting for results is this: ".stluser emas ,gnirts weN"
I am looking for this: "weN gnirts... "
Here is a jsbin
Try something like this.
function wordsReverser(string){
return string.split("").reverse().join("").split(" ").reverse().join(" ")
}
console.log(wordsReverser('New string, same results.'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With