here's my take on it with ES7
const capitalize = ([initial, ...rest]) => `${initial.toUpperCase()}${rest.join('').toLowerCase()}`;
a little cleaner
const capitalize = input => { const [initial, ...rest] = input; const capitalizedInitial = initial.toUpperCase(); const loweredBody = rest.join('').toLowerCase(); return `${capitalizedInitial}${loweredBody}`; };
One-liner solutions are most of the time my favs too! 😜
const [initial, ...rest] = input;
I didn't think of it that way. I like it!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
here's my take on it with ES7
a little cleaner
One-liner solutions are most of the time my favs too! 😜
I didn't think of it that way. I like it!