10 JavaScript One-liners You Have Got to Add Your Arsenal as a Developer
Step Up your JavaScript game in just a couple of minutes
Published in
5 min readNov 30, 2020
JavaScript can do a lot of amazing things!
From complex frameworks to handling API’s, there is just SO much to learn.
But, it also enables you to do some awesome stuff using just one single line.
Check out these 10 one-liners to step up your JavaScript game!
1. Capitalize the first letter of a string
Using this function, you’ll be able to capitalize the first letter of the input of a string. This could be a single word, but also an entire sentence.
// Capitalize the first letter of a string
const capitalize = str => `${str.charAt(0).toUpperCase()}${str.slice(1)}`;capitalize("hello, you are a cool person!");
// Result: "Hello, you are a cool person!"