"use strict" const bigword = (str) => { let result = ""; let b = true; for (let i = 0; i < str.length; i++){ result += b ? str[i].toUpperCase() : str.charAt(i); b = str.charAt(i) === " ";} return result; } alert(bigword(" привет тест"));