Skip to content

Commit d24e472

Browse files
committed
solve: forEachFilterIsNaN, forEachMap, forEachReduce
1 parent a9449f2 commit d24e472

File tree

6 files changed

+39
-0
lines changed

6 files changed

+39
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 설명
2+
3+
배열 원소중 숫자인 원소만 뽑아 배열을 만드세요.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const inputArray = [-3, -2, -1, 0, 1, 2, 3, '1', 'jmjmjm'];
2+
3+
const answer = [];
4+
5+
inputArray.forEach(e => {
6+
if (Number.isInteger(e)) {
7+
answer.push(e)
8+
}
9+
})
10+
console.log(answer);
11+

Challenge/JM Lim/forEachMap/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 설명
2+
3+
forEach 메소드를 사용해서 배열의 각 원소 끝에 '%'를 붙인 문자열 배열을 출력하세요

Challenge/JM Lim/forEachMap/solve.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const inputArray = [100, 10, 20, 40];
2+
3+
const answer = [];
4+
5+
inputArray.forEach(e => {
6+
let val = e+'';
7+
answer.push(val.concat('%'))
8+
})
9+
10+
console.log(answer);
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 설명
2+
3+
forEach 메소드를 사용해서 배열의 총 합을 출력하는 코드를 작성하세요
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const inputArray = [120, -20, -30, 0, 15];
2+
3+
let answer = '';
4+
5+
answer = inputArray.reduce((a, c) => {
6+
return a+c
7+
}, 0)
8+
9+
console.log(answer);

0 commit comments

Comments
 (0)