Skip to content

Commit

Permalink
내용추가: rest parameter 이용한 최솟값 구하기
Browse files Browse the repository at this point in the history
* apply 메서드를 활용해 최솟값을 구하는 방법은 ES5

* ES6의 rest parameter 활용한 방법을 추가.
  • Loading branch information
eve712 committed Nov 22, 2020
1 parent 54053f1 commit 008c74c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions 학습정리 모음/학습정리1120.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ function getMinMultiple(grade) {

### ✱Math.min.apply(null, arr);
```javascript
function getMinMultiple(grade) {
Math.min.apply(null, multipleOfFive);
}
Math.min.apply(null, multipleOfFive); // ES5
Math.min(...multipleOfFive); // ES6
```
처음에는 배열에서 최소값을 찾는 방법을 구글링 해서 Math()메서드를 사용하려 했다.<br>
그러나 이렇게 하면, `multipleOfFive` **배열의 모든 원소 중 최소값을 반환**하기 때문에 grade값보다 크다는 조건을 추가하기 어렵다.
Expand Down

0 comments on commit 008c74c

Please sign in to comment.