Update solution

This commit is contained in:
aruseni 2019-07-01 06:03:30 +03:00 committed by GitHub
parent 6bbe0b4313
commit 1b05095b17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,7 +6,7 @@ But we can make a new string based on the existing one, with the uppercased firs
let newStr = str[0].toUpperCase() + str.slice(1); let newStr = str[0].toUpperCase() + str.slice(1);
``` ```
There's a small problem though. If `str` is empty, then `str[0]` is undefined, so we'll get an error. There's a small problem though. If `str` is empty, then `str[0]` is `undefined`, and as `undefined` doesn't have the `toUpperCase()` method, we'll get an error.
There are two variants here: There are two variants here: