Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
var reverseWords = function(s) {
let res = '';
let word = '';
for (let c of s) {
if (c === ' ') {
res += word + c;
word = '';
} else {
word = c + word;
}
}
return res + word;
};