+ 2

How can we do easier way in this letter by letter string, to make the first letter capital,

function witParameter(x){ for(var i =0; i<x.length ; i++){ var x = x.charAt(0).toUpperCase()+x.toLowerCase().slice(1) console.log(x[i]) } } witParameter("strings")

15th Jul 2020, 1:39 PM
Abdihakim Ismail
Abdihakim Ismail - avatar
5 Antworten
+ 3
Thank you, that's pretty good!
15th Jul 2020, 1:52 PM
Abdihakim Ismail
Abdihakim Ismail - avatar
+ 2
Like this? function witParameter(x){ console.log(x[0].toUpperCase()); for(var i=1; i<x.length ; i++) { console.log(x[i].toLowerCase()); } }
15th Jul 2020, 1:47 PM
HonFu
HonFu - avatar
+ 1
15th Jul 2020, 3:32 PM
ODLNT
ODLNT - avatar
+ 1
ODLNT. seems little bit advanced, But took it as coming necessities.
15th Jul 2020, 4:03 PM
Abdihakim Ismail
Abdihakim Ismail - avatar