Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capitalize: lowercase the rest of the string? #16

Closed
proustibat opened this issue Dec 12, 2017 · 3 comments
Closed

Capitalize: lowercase the rest of the string? #16

proustibat opened this issue Dec 12, 2017 · 3 comments
Labels
enhancement An exciting new feature or addition.

Comments

@proustibat
Copy link

We could maybe consider that if we call capitalize on a string, we expect the first letter to be uppercase but the rest to be in lowercase ?
I suggest we could add it as follows:
var capitalize = str => str[0].toUpperCase() + str.slice(1).toLowerCase();

or with a default option as follows:
var capitalize = (str, lowerRest=true) => str[0].toUpperCase() + (lowerRest ? str.slice(1).toLowerCase() : str.slice(1));

@Chalarangelo
Copy link
Owner

Good idea! I prefer the default option idea, as it is more like progressive enhancement for the snippet. I would also argue that lowerRest should default to false, to avoid confusion, but I might be in the minority here.

@Chalarangelo Chalarangelo added the enhancement An exciting new feature or addition. label Dec 12, 2017
@Chalarangelo
Copy link
Owner

Just added this to the existing snippet. Thanks for the idea!

@lock
Copy link

lock bot commented Dec 18, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for any follow-up tasks.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement An exciting new feature or addition.
Projects
None yet
Development

No branches or pull requests

2 participants