From 1311feb4625f9c8a5c43d945cb12a20c28b93bbe Mon Sep 17 00:00:00 2001 From: Taeyang Kim Date: Mon, 6 Sep 2021 18:21:18 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[=EB=82=98=EB=A8=B8=EC=A7=80=20=EB=A7=A4?= =?UTF-8?q?=EA=B0=9C=EB=B3=80=EC=88=98=EC=99=80=20=EC=A0=84=EA=B0=9C=20?= =?UTF-8?q?=EB=AC=B8=EB=B2=95]=20=EB=B3=B8=EB=AC=B8=20=EB=B2=88=EC=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../02-rest-parameters-spread/article.md | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/1-js/06-advanced-functions/02-rest-parameters-spread/article.md b/1-js/06-advanced-functions/02-rest-parameters-spread/article.md index 280986d4bf..66be690005 100644 --- a/1-js/06-advanced-functions/02-rest-parameters-spread/article.md +++ b/1-js/06-advanced-functions/02-rest-parameters-spread/article.md @@ -225,49 +225,49 @@ alert( Array.from(str) ); // H,e,l,l,o 이런 이유때문에 무언가를 배열로 바꿀 때는 전개 문법보다 `Array.from`이 보편적으로 사용됩니다. -## Get a new copy of an array/object +## 배열 / 객체의 사본 만들기 -Remember when we talked about `Object.assign()` [in the past](info:object-copy#cloning-and-merging-object-assign)? +객체를 복사하기 위해 `Object.assign()`을 [공부했던 것](info:object-copy#cloning-and-merging-object-assign)을 기억하시나요? -It is possible to do the same thing with the spread syntax. +전개 연산자를 사용해서 동일한 작업을 할 수 있습니다. ```js run let arr = [1, 2, 3]; -let arrCopy = [...arr]; // spread the array into a list of parameters - // then put the result into a new array +let arrCopy = [...arr]; // 기존 배열을 매개변수로 전달하여 + // 그 결과를 새 배열에 넣습니다. -// do the arrays have the same contents? +// 두 배열의 내용이 동일합니까? alert(JSON.stringify(arr) === JSON.stringify(arrCopy)); // true -// are the arrays equal? -alert(arr === arrCopy); // false (not same reference) +// 두 배열이 동일합니까? +alert(arr === arrCopy); // false (참조가 다름) -// modifying our initial array does not modify the copy: +// 원본 배열을 수정해도 사본 배열은 변하지 않습니다. arr.push(4); alert(arr); // 1, 2, 3, 4 alert(arrCopy); // 1, 2, 3 ``` -Note that it is possible to do the same thing to make a copy of an object: +객체의 사본을 만드는 것도 동일합니다. ```js run let obj = { a: 1, b: 2, c: 3 }; -let objCopy = { ...obj }; // spread the object into a list of parameters - // then return the result in a new object +let objCopy = { ...obj }; // 기존 객체를 매개변수로 전달하여 + // 그 결과를 새 객체에 넣습니다. -// do the objects have the same contents? +// 두 객체의 내용이 동일합니까? alert(JSON.stringify(obj) === JSON.stringify(objCopy)); // true -// are the objects equal? -alert(obj === objCopy); // false (not same reference) +// 두 객체가 동일합니까? +alert(obj === objCopy); // false (참조가 다름) -// modifying our initial object does not modify the copy: +// 원본 객체를 수정해도 사본 객체는 변하지 않습니다. obj.d = 4; alert(JSON.stringify(obj)); // {"a":1,"b":2,"c":3,"d":4} alert(JSON.stringify(objCopy)); // {"a":1,"b":2,"c":3} ``` -This way of copying an object is much shorter than `let objCopy = Object.assign({}, obj);` or for an array `let arrCopy = Object.assign([], arr);` so we prefer to use it whenever we can. +객체에 `let objCopy = Object.assign({}, obj);`를, 배열에 `let arrCopy = Object.assign([], arr)`을 사용하는 것보다 이 방법으로 복사하는 것이 코드가 짧기에 가능한 한 이 방법을 사용하는 것이 좋습니다. ## 요약 From 52439a51d29e1ba6b65db3f6c485700d25bde273 Mon Sep 17 00:00:00 2001 From: Taeyang Kim Date: Mon, 6 Sep 2021 18:22:52 +0900 Subject: [PATCH 2/3] =?UTF-8?q?Revert=20"[=EB=82=98=EB=A8=B8=EC=A7=80=20?= =?UTF-8?q?=EB=A7=A4=EA=B0=9C=EB=B3=80=EC=88=98=EC=99=80=20=EC=A0=84?= =?UTF-8?q?=EA=B0=9C=20=EB=AC=B8=EB=B2=95]=20=EB=B3=B8=EB=AC=B8=20?= =?UTF-8?q?=EB=B2=88=EC=97=AD"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 1311feb4 --- .../02-rest-parameters-spread/article.md | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/1-js/06-advanced-functions/02-rest-parameters-spread/article.md b/1-js/06-advanced-functions/02-rest-parameters-spread/article.md index 66be690005..280986d4bf 100644 --- a/1-js/06-advanced-functions/02-rest-parameters-spread/article.md +++ b/1-js/06-advanced-functions/02-rest-parameters-spread/article.md @@ -225,49 +225,49 @@ alert( Array.from(str) ); // H,e,l,l,o 이런 이유때문에 무언가를 배열로 바꿀 때는 전개 문법보다 `Array.from`이 보편적으로 사용됩니다. -## 배열 / 객체의 사본 만들기 +## Get a new copy of an array/object -객체를 복사하기 위해 `Object.assign()`을 [공부했던 것](info:object-copy#cloning-and-merging-object-assign)을 기억하시나요? +Remember when we talked about `Object.assign()` [in the past](info:object-copy#cloning-and-merging-object-assign)? -전개 연산자를 사용해서 동일한 작업을 할 수 있습니다. +It is possible to do the same thing with the spread syntax. ```js run let arr = [1, 2, 3]; -let arrCopy = [...arr]; // 기존 배열을 매개변수로 전달하여 - // 그 결과를 새 배열에 넣습니다. +let arrCopy = [...arr]; // spread the array into a list of parameters + // then put the result into a new array -// 두 배열의 내용이 동일합니까? +// do the arrays have the same contents? alert(JSON.stringify(arr) === JSON.stringify(arrCopy)); // true -// 두 배열이 동일합니까? -alert(arr === arrCopy); // false (참조가 다름) +// are the arrays equal? +alert(arr === arrCopy); // false (not same reference) -// 원본 배열을 수정해도 사본 배열은 변하지 않습니다. +// modifying our initial array does not modify the copy: arr.push(4); alert(arr); // 1, 2, 3, 4 alert(arrCopy); // 1, 2, 3 ``` -객체의 사본을 만드는 것도 동일합니다. +Note that it is possible to do the same thing to make a copy of an object: ```js run let obj = { a: 1, b: 2, c: 3 }; -let objCopy = { ...obj }; // 기존 객체를 매개변수로 전달하여 - // 그 결과를 새 객체에 넣습니다. +let objCopy = { ...obj }; // spread the object into a list of parameters + // then return the result in a new object -// 두 객체의 내용이 동일합니까? +// do the objects have the same contents? alert(JSON.stringify(obj) === JSON.stringify(objCopy)); // true -// 두 객체가 동일합니까? -alert(obj === objCopy); // false (참조가 다름) +// are the objects equal? +alert(obj === objCopy); // false (not same reference) -// 원본 객체를 수정해도 사본 객체는 변하지 않습니다. +// modifying our initial object does not modify the copy: obj.d = 4; alert(JSON.stringify(obj)); // {"a":1,"b":2,"c":3,"d":4} alert(JSON.stringify(objCopy)); // {"a":1,"b":2,"c":3} ``` -객체에 `let objCopy = Object.assign({}, obj);`를, 배열에 `let arrCopy = Object.assign([], arr)`을 사용하는 것보다 이 방법으로 복사하는 것이 코드가 짧기에 가능한 한 이 방법을 사용하는 것이 좋습니다. +This way of copying an object is much shorter than `let objCopy = Object.assign({}, obj);` or for an array `let arrCopy = Object.assign([], arr);` so we prefer to use it whenever we can. ## 요약 From 82ee28e25d99ff3ef7c88f467a30dab0af11a4b3 Mon Sep 17 00:00:00 2001 From: Taeyang Kim Date: Tue, 7 Sep 2021 13:09:11 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[Part=201.=205.2=20=EC=88=AB=EC=9E=90?= =?UTF-8?q?=ED=98=95]=20=EA=B3=BC=EC=A0=9C=20=EB=B2=88=EC=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../4-endless-loop-error/solution.md | 10 ++--- .../02-number/4-endless-loop-error/task.md | 4 +- .../02-number/8-random-min-max/solution.md | 10 ++--- .../02-number/8-random-min-max/task.md | 8 ++-- .../9-random-int-min-max/solution.md | 38 +++++++++---------- .../02-number/9-random-int-min-max/task.md | 11 +++--- 6 files changed, 41 insertions(+), 40 deletions(-) diff --git a/1-js/05-data-types/02-number/4-endless-loop-error/solution.md b/1-js/05-data-types/02-number/4-endless-loop-error/solution.md index 8bc55bd027..2fbcaa6a93 100644 --- a/1-js/05-data-types/02-number/4-endless-loop-error/solution.md +++ b/1-js/05-data-types/02-number/4-endless-loop-error/solution.md @@ -1,6 +1,6 @@ -That's because `i` would never equal `10`. +`i`는 절대 `10`이 될 수 없기 때문입니다. -Run it to see the *real* values of `i`: +실행하여 `i`의 *실제* 값을 확인해봅시다: ```js run let i = 0; @@ -10,8 +10,8 @@ while (i < 11) { } ``` -None of them is exactly `10`. +어떤 것도 정확히 `10`이 되지 않습니다. -Such things happen because of the precision losses when adding fractions like `0.2`. +`0.2`와 같은 소수를 더하면 정밀도가 떨어지기 때문입니다. -Conclusion: evade equality checks when working with decimal fractions. \ No newline at end of file +결론: 소수를 다룰 때는 동등 연산자 비교를 지양합시다. \ No newline at end of file diff --git a/1-js/05-data-types/02-number/4-endless-loop-error/task.md b/1-js/05-data-types/02-number/4-endless-loop-error/task.md index 592ece31c0..9053a82108 100644 --- a/1-js/05-data-types/02-number/4-endless-loop-error/task.md +++ b/1-js/05-data-types/02-number/4-endless-loop-error/task.md @@ -2,9 +2,9 @@ importance: 4 --- -# An occasional infinite loop +# 간헐적 무한루프 -This loop is infinite. It never ends. Why? +이것은 무한루프입니다. 끝나질 않죠. 왜 그럴까요? ```js let i = 0; diff --git a/1-js/05-data-types/02-number/8-random-min-max/solution.md b/1-js/05-data-types/02-number/8-random-min-max/solution.md index 8736c3d561..becae67a19 100644 --- a/1-js/05-data-types/02-number/8-random-min-max/solution.md +++ b/1-js/05-data-types/02-number/8-random-min-max/solution.md @@ -1,11 +1,11 @@ -We need to "map" all values from the interval 0..1 into values from `min` to `max`. +먼저 0..1 구간의 모든 값을 `min`과 `max`의 사이가 될 수 있도록 매핑해야 합니다. -That can be done in two stages: +두 단계로 수행할 수 있습니다. -1. If we multiply a random number from 0..1 by `max-min`, then the interval of possible values increases `0..1` to `0..max-min`. -2. Now if we add `min`, the possible interval becomes from `min` to `max`. +1. 0..1 사이의 무작위 숫자를 `max-min`으로 곱한다면, 가능한 값의 구간은 `0..1`에서 `0..max-min`이 됩니다. +2. 이제 `min`을 더해주면, 가능한 구간은 `min` 이상 `max` 미만이 됩니다. -The function: +답안: ```js run function random(min, max) { diff --git a/1-js/05-data-types/02-number/8-random-min-max/task.md b/1-js/05-data-types/02-number/8-random-min-max/task.md index 7037cfcbb9..f8a50b9237 100644 --- a/1-js/05-data-types/02-number/8-random-min-max/task.md +++ b/1-js/05-data-types/02-number/8-random-min-max/task.md @@ -2,13 +2,13 @@ importance: 2 --- -# A random number from min to max +# min 이상 max 미만 무작위 숫자 -The built-in function `Math.random()` creates a random value from `0` to `1` (not including `1`). +내장 함수 `Math.random()`은 `0` 이상 `1` 미만의 무작위 값을 생성합니다. -Write the function `random(min, max)` to generate a random floating-point number from `min` to `max` (not including `max`). +`min` 이상 `max` 미만의 무작위 부동소수점 숫자를 생성하는 함수 `random(min, max)`을 작성해 보세요. -Examples of its work: +예시: ```js alert( random(1, 5) ); // 1.2345623452 diff --git a/1-js/05-data-types/02-number/9-random-int-min-max/solution.md b/1-js/05-data-types/02-number/9-random-int-min-max/solution.md index 0950ff812f..c416f6814a 100644 --- a/1-js/05-data-types/02-number/9-random-int-min-max/solution.md +++ b/1-js/05-data-types/02-number/9-random-int-min-max/solution.md @@ -1,6 +1,6 @@ -# The simple but wrong solution +# 간단하지만 틀린 답안 -The simplest, but wrong solution would be to generate a value from `min` to `max` and round it: +가장 간단하지만 잘못된 답안은 `min`부터 `max`까지 값을 생성하고 반올림하는 것입니다. ```js run function randomInteger(min, max) { @@ -11,28 +11,28 @@ function randomInteger(min, max) { alert( randomInteger(1, 3) ); ``` -The function works, but it is incorrect. The probability to get edge values `min` and `max` is two times less than any other. +기능은 동작하나 부정확합니다. 모서릿값인 `min`과 `max`가 나올 확률이 다른 것보다 두 배 적습니다. -If you run the example above many times, you would easily see that `2` appears the most often. +위 예제를 여러 번 실행한다면 `2`가 가장 많이 나타난다는 것을 알 수 있습니다. -That happens because `Math.round()` gets random numbers from the interval `1..3` and rounds them as follows: +이는 `Math.round()`가 `1..3` 구간의 무작위 숫자를 다음과 같이 반올림하기 때문입니다. ```js no-beautify -values from 1 ... to 1.4999999999 become 1 -values from 1.5 ... to 2.4999999999 become 2 -values from 2.5 ... to 2.9999999999 become 3 +1 부터 ... 1.4999999999 까지의 값은 1 이 됩니다. +1.5 부터 ... 2.4999999999 까지의 값은 2 이 됩니다. +2.5 부터 ... 2.9999999999 까지의 값은 3 이 됩니다. ``` -Now we can clearly see that `1` gets twice less values than `2`. And the same with `3`. +`1`이 `2`보다 두 배 적게 나오는 것을 볼 수 있죠. `3`도 마찬가지입니다. -# The correct solution +# 올바른 답안 -There are many correct solutions to the task. One of them is to adjust interval borders. To ensure the same intervals, we can generate values from `0.5 to 3.5`, thus adding the required probabilities to the edges: +여러 답안이 있지만 그중 하나는 구간 경계를 조정하는 것입니다. 동일한 구간을 보장하기 위해 `0.5 에서 3.5` 구간의 값을 생성하여 모서릿값에 필요한 확률을 더할 수 있습니다. ```js run *!* function randomInteger(min, max) { - // now rand is from (min-0.5) to (max+0.5) + // rand 는 (min-0.5) 부터 (max+0.5) 까지입니다. let rand = min - 0.5 + Math.random() * (max - min + 1); return Math.round(rand); } @@ -41,12 +41,12 @@ function randomInteger(min, max) { alert( randomInteger(1, 3) ); ``` -An alternative way could be to use `Math.floor` for a random number from `min` to `max+1`: +다른 방법으로는 `Math.floor`를 이용하여 `min`부터 `max+1`까지의 무작위 숫자를 만드는 것입니다. ```js run *!* function randomInteger(min, max) { - // here rand is from min to (max+1) + // 여기서 rand 는 min 부터 (max+1) 까지입니다. let rand = min + Math.random() * (max + 1 - min); return Math.floor(rand); } @@ -55,12 +55,12 @@ function randomInteger(min, max) { alert( randomInteger(1, 3) ); ``` -Now all intervals are mapped this way: +모든 구간이 다음과 같이 매핑되었습니다: ```js no-beautify -values from 1 ... to 1.9999999999 become 1 -values from 2 ... to 2.9999999999 become 2 -values from 3 ... to 3.9999999999 become 3 +1 부터 ... 1.9999999999 까지의 값은 1 이 됩니다. +2 부터 ... 2.9999999999 까지의 값은 2 가 됩니다. +3 부터 ... 3.9999999999 까지의 값은 3 이 됩니다. ``` -All intervals have the same length, making the final distribution uniform. +모든 구간의 길이가 동일해졌고, 최종 분포도 균일해졌습니다. diff --git a/1-js/05-data-types/02-number/9-random-int-min-max/task.md b/1-js/05-data-types/02-number/9-random-int-min-max/task.md index 4ac7b5fbbd..bce819d402 100644 --- a/1-js/05-data-types/02-number/9-random-int-min-max/task.md +++ b/1-js/05-data-types/02-number/9-random-int-min-max/task.md @@ -2,14 +2,15 @@ importance: 2 --- -# A random integer from min to max +# min 이상 max 미만 무작위 정수 -Create a function `randomInteger(min, max)` that generates a random *integer* number from `min` to `max` including both `min` and `max` as possible values. +`min` 이상 `max` 이하의 무작위 *정수*를 생성하는 함수 `randomInteger(min, max)`를 작성해 보세요. -Any number from the interval `min..max` must appear with the same probability. +`min..max` 구간의 어느 숫자라도 같은 확률로 나타나야 합니다. -Examples of its work: + +예시: ```js alert( randomInteger(1, 5) ); // 1 @@ -17,4 +18,4 @@ alert( randomInteger(1, 5) ); // 3 alert( randomInteger(1, 5) ); // 5 ``` -You can use the solution of the [previous task](info:task/random-min-max) as the base. +[위 문제](info:task/random-min-max)의 답안을 토대로 사용해도 됩니다. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy