Last active
January 20, 2021 19:20
-
-
Save bobdobbalina/47330cc70248315e1bdccfb430dce36a to your computer and use it in GitHub Desktop.
Javascript: Capitalize the first letter in a string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const capitalize = ([first, ...rest], lowerRest = false) => | |
first.toUpperCase() + (lowerRest ? rest.join('').toLowerCase() : rest.join('')); | |
capitalize('JavaScript'); // 'JavaScript ' | |
capitalize('JavaScript', true); // 'Javascript's |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment