We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 71ab899 commit 70a578cCopy full SHA for 70a578c
1 file changed
1-js/05-data-types/03-string/1-ucfirst/solution.md
@@ -8,16 +8,7 @@ let newStr = str[0].toUpperCase() + str.slice(1);
8
9
그런데 이렇게 코드를 작성하면 `str`이 비어있는 문자열인 경우 `str[0]`이 `undefined`가 되는 문제가 발생합니다. `undefined`는 `toUpperCase()`메서드를 지원하지 않으므로 에러가 발생하죠.
10
11
-<<<<<<< HEAD
12
-두 가지 방법을 사용해 이런 예외사항을 처리 할 수 있습니다.
13
-
14
-1. `str.charAt(0)`은 `str`이 비어있는 문자열이더라도 항상 문자열을 반환하므로, 이 메서드를 사용합니다.
15
-2. 빈 문자열인지를 확인하는 코드를 작성합니다.
16
17
-두 번째 방법을 사용하여 작성한 답안은 아래와 같습니다.
18
-=======
19
-The easiest way out is to add a test for an empty string, like this:
20
->>>>>>> upstream/master
+가장 간단한 해결 방법은 아래처럼 빈 문자열인지 확인하는 조건을 추가하는 것입니다.
21
22
```js run demo
23
function ucFirst(str) {
@@ -27,4 +18,4 @@ function ucFirst(str) {
27
}
28
29
alert( ucFirst("john") ); // John
30
-```
+```
0 commit comments