js reverse odd length words code example
Example: js reverse odd length words
// Reverse the Odd Length Words
function reverseOdd(str) {
return str.split(" ").map(w => w.length%2 ? [...w].reverse().join("") : w).join(" ");
}
console.log(reverseOdd("Bananas")); // "sananaB"
console.log(reverseOdd("One two three four")); // "enO owt eerht four"