Con JavaScript possiamo implementare la funzione ucwords() di PHP.
La soluzione รจ la seguente:
'use strict';
const ucwords = str => {
return str.split(/\s/).map(w => { return w.charAt(0).toUpperCase() + w.substring(1); }).join(' ');
};