Answers for "js reverse odd length words"

0

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"
Posted by: Guest on March-16-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language