DEV Community

Discussion on: Web Basics: How to Capitalize a Word in JavaScript

Collapse
 
kurisutofu profile image
kurisutofu • Edited

Not as fancy as other solutions but I believe this works.

const capitalize = (str) => str.charAt(0).toUpperCase() + str.substr(1).toLowerCase();
Collapse
 
samanthaming profile image
Samantha Ming

No need to always be fancy. This works perfectly! Great πŸ‘