uppercase fist letter in a object (JS) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

uppercase fist letter in a object (JS)

how do you uppercase the first letter in a javascript object? example let k = name: "ken", job: "digging", age: 80} ; to let k = name: "Ken", job: "Digging", age: 80} ;

17th Jan 2018, 6:40 AM
Matthew Mubarak
Matthew Mubarak - avatar
3 Answers
+ 11
by iterating the keys and re-assigning string values however you want * can probably do a much better code than this, just an example of a possible implementation https://code.sololearn.com/WNOE9is18K1v/?ref=app
17th Jan 2018, 7:51 AM
Burey
Burey - avatar
+ 5
k.name = k.name.charAt(0).toUpperCase() + k.name.substr(1);
17th Jan 2018, 7:47 AM
AtoMX
AtoMX - avatar
+ 2
Thanks for the help fellows
17th Jan 2018, 4:43 PM
Matthew Mubarak
Matthew Mubarak - avatar