JavaScript: Convert last character of each word to uppercase

Table of contents

No heading

No headings in the article.

function changeLastCharacterToUpperCase (str) {
  return str.split(" ").map( (item) => {
    return item.slice(0, -1) + item[item.length - 1].toUpperCase();
  }).join (" ");
}

console.log(changeLastCharacterToUpperCase('hello world welcome testing a b javascript'));
Output:
hellO worlD welcomE testinG A B javascripT

Execute above code here