console.log(abbrev_name("Robin Singh"));
function abbrev_name(str)
{
var temp = str.split('');
var ar = [];
for(var i =0 ; i<temp.length ; i++)
{
// ar.push(temp[i]);
if(temp[i] == ' ')
{
ar.push(temp[i])
ar.push(temp[i+1]);
break;
}
ar.push(temp[i]);
}
return ar.join('');
}
To embed this program on your website, copy the following code and paste it into your website's HTML: