let a = "JavaScript is a good language"; let b = ''; for (let i = 0; i < a.length; i++) { b += (a[i - 1] == ' ') ? a[i].toUpperCase() : a[i]; } console.log(b);