DEV Community

Discussion on: 1 line of code: How to capitalise a string

Collapse
 
jamesthomson profile image
James Thomson

Slightly more succinct version

const capitalise = (str) => `${str[0].toUpperCase()}${str.slice(1)}`;
Enter fullscreen mode Exit fullscreen mode
Collapse
 
martinkr profile image
Martin Krause

Hi James,

thank you for your contribution, as your code is just a little bit faster according to perf.link, I updated the article and the code.

Cheers!