Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions 1-js/05-data-types/03-string/1-ucfirst/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,7 @@ let newStr = str[0].toUpperCase() + str.slice(1);

그런데 이렇게 코드를 작성하면 `str`이 비어있는 문자열인 경우 `str[0]`이 `undefined`가 되는 문제가 발생합니다. `undefined`는 `toUpperCase()`메서드를 지원하지 않으므로 에러가 발생하죠.

<<<<<<< HEAD
두 가지 방법을 사용해 이런 예외사항을 처리 할 수 있습니다.

1. `str.charAt(0)`은 `str`이 비어있는 문자열이더라도 항상 문자열을 반환하므로, 이 메서드를 사용합니다.
2. 빈 문자열인지를 확인하는 코드를 작성합니다.

두 번째 방법을 사용하여 작성한 답안은 아래와 같습니다.
=======
The easiest way out is to add a test for an empty string, like this:
>>>>>>> upstream/master
가장 간단한 해결 방법은 아래처럼 빈 문자열인지 확인하는 조건을 추가하는 것입니다.

```js run demo
function ucFirst(str) {
Expand All @@ -27,4 +18,4 @@ function ucFirst(str) {
}

alert( ucFirst("john") ); // John
```
```
8 changes: 2 additions & 6 deletions 1-js/05-data-types/03-string/3-truncate/solution.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
새로 만든 문자열의 길이는 `maxlength`가 되어야 하므로, 생략 부호 `"…"`가 차지할 길이를 생각하여 함수를 만들어야 합니다.

<<<<<<< HEAD
생략 부호는 유니코드에 등록된 독립된 글자임에 유의하여 답안을 작성해야 합니다. 점 세 개가 아님에 유의하시기 바랍니다.
=======
Note that there is actually a single Unicode character for an ellipsis. That's not three dots.
>>>>>>> upstream/master
생략 부호는 유니코드에 등록된 하나의 문자입니다. 점 세 개가 아님에 유의하세요.

```js run demo
function truncate(str, maxlength) {
return (str.length > maxlength) ?
str.slice(0, maxlength - 1) + '…' : str;
}
```
```
381 changes: 37 additions & 344 deletions 1-js/05-data-types/03-string/article.md

Large diffs are not rendered by default.

10 changes: 0 additions & 10 deletions 1-js/05-data-types/04-array/10-maximal-subarray/solution.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,9 @@ alert( getMaxSubSum([1, 2, 3]) ); // 6
alert( getMaxSubSum([100, -9, 2, -3, 5]) ); // 100
```

<<<<<<< HEAD
이렇게 구현하면 시간 복잡도가 [O(n<sup>2</sup>)](https://en.wikipedia.org/wiki/Big_O_notation)이 됩니다. 이는 배열의 크기를 2배 늘리면 알고리즘은 4배나 더 오래 걸린다는 의미입니다.

크기가 큰 배열(1000, 10000 또는 그 이상의 요소를 가진 배열)에 위와 같은 알고리즘을 적용하면 매우 느릴 수 있습니다.
=======
The solution has a time complexity of [O(n<sup>2</sup>)](https://en.wikipedia.org/wiki/Big_O_notation). In other words, if we increase the array size 2 times, the algorithm will work 4 times longer.

For big arrays (1000, 10000 or more items) such algorithms can lead to serious sluggishness.
>>>>>>> upstream/master

# 빠른 해답

Expand Down Expand Up @@ -97,8 +91,4 @@ alert( getMaxSubSum([-1, -2, -3]) ); // 0

이 알고리즘은 정확히 한번 배열을 순회하므로 시간 복잡도는 O(n)입니다.

<<<<<<< HEAD
알고리즘에 대한 상세한 정보는 [최대합 부분 배열 문제](http://en.wikipedia.org/wiki/Maximum_subarray_problem)에서 찾을 수 있습니다. 동작원리에 대해 확실히 이해가 되지 않았다면 위 예제의 알고리즘이 어떻게 동작하는지 찬찬히 살펴보세요. 글을 읽는 것보다 코드를 살펴보는게 훨씬 도움이 될 겁니다.
=======
You can find more detailed information about the algorithm here: [Maximum subarray problem](http://en.wikipedia.org/wiki/Maximum_subarray_problem). If it's still not obvious why that works, then please trace the algorithm on the examples above, see how it works, that's better than any words.
>>>>>>> upstream/master
10 changes: 1 addition & 9 deletions 1-js/05-data-types/04-array/2-create-array/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,11 @@ importance: 5

배열과 관련된 다섯 가지 연산을 해봅시다.

<<<<<<< HEAD
1. 요소 "Jazz", "Blues"가 있는 `styles` 배열을 생성합니다.
2. "Rock-n-Roll"을 배열 끝에 추가합니다.
3. 배열 정 중앙에 있는 요소를 "Classics"로 바꿉니다. 가운데 요소를 찾는 코드는 요소가 홀수 개인 배열에서도 잘 작동해야 합니다.
3. 배열 정중앙에 있는 요소를 "Classics"로 바꿉니다. 가운데 요소를 찾는 코드는 요소가 홀수 개인 배열에서도 잘 작동해야 합니다.
4. 배열의 첫 번째 요소를 꺼내서 출력합니다.
5. "Rap"과 "Reggae"를 배열의 앞에 추가합니다.
=======
1. Create an array `styles` with items "Jazz" and "Blues".
2. Append "Rock-n-Roll" to the end.
3. Replace the value in the middle with "Classics". Your code for finding the middle value should work for any arrays with odd length.
4. Strip off the first value of the array and show it.
5. Prepend `Rap` and `Reggae` to the array.
>>>>>>> upstream/master

단계를 하나씩 거칠 때마다 배열 모습은 아래와 같이 변해야 합니다.

Expand Down
Loading