JSFiddle - React, Tailwind, and code Playground
JavaScript
function solution(str) {
return [].join.call(
$( str = str.split("") ).map(function (index) {
return !index || $(str).get(index - 1) === " " ? this.toUpperCase() : this;
})
, "");
}
alert( solution("hellou, world") );