You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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));
The text was updated successfully, but these errors were encountered:
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.
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.
lockbot
locked as resolved and limited conversation to collaborators
Dec 18, 2019
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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));
The text was updated successfully, but these errors were encountered: