Update solution
This commit is contained in:
parent
6bbe0b4313
commit
1b05095b17
1 changed files with 1 additions and 1 deletions
|
@ -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:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue