console.log(capitalize_Words('js string exercises'));
function capitalize_Words(str)
{
 var temp = str.split('');
    var ar = [];
    for(var i = 0 ; i < temp.length ; i++)
    {
        if(i==0)
        {
            ar[i]= temp[i].toUpperCase();
            continue
        }
        ar.push(temp[i])
        if(temp[i] == ' ')
        {
            ar[i]=temp[i+1].toUpperCase();
            continue
        }
    }
    return ar.join('')
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: