You can omit the second argument in substring, substr and slice to get the rest of the string until the end. You can also use charAt(0) or even .charAt() to get the first char instead of a slicing method.
substring
substr
slice
charAt(0)
.charAt()
const capitalize = str => str .toLowerCase() .split(' ') .map(strWord => strWord.charAt().toUpperCase() + strWord.slice(1)) .join(' ')
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.
You can omit the second argument in
substring
,substr
andslice
to get the rest of the string until the end.You can also use
charAt(0)
or even.charAt()
to get the first char instead of a slicing method.