Write a javascript program to capitalize the first letter of each word of a given string
Answers
Answered by
0
public static void main(String arg[])
{
String str1=""
int I, p
Char chr,chr1
Str=' '+str
P=str.length()
For (i=0 ;i<p ;i++)
{
Chr=str.charAt(0)
If(chr==' ')
{
Chr=str+charAt(i+1)
Str1=str+' '+Character. toUpperCase(chr1)
i=i+1
}
Else
Str1=Str1+chr
}
System. out. println(str1)
}
}
// program ends
shrushti771:
Nice answer
Answered by
0
Hi
function capitalizeItPlz (str) {
// split characters
let arr = str.split("");
// capitalize first character
arr[0] = arr[0].toUpperCase();
// return capitalized string
let finalStr = arr.join("");
// Write output in console
console.log(finalStr);
};
capitalizeItPlz('ajay rawat');
Attachments:
Similar questions