console.log(capitalize('js string exercises'));

function capitalize(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])
       
    }
    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: