Merge pull request #1103 from aruseni/patch-6

Update solution
This commit is contained in:
Ilya Kantor 2019-07-01 12:47:02 +03:00 committed by GitHub
commit 81e45f0938
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);
```
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: