Skip to content

Commit 21bfc53

Browse files
authored
Merge pull request #169 from Jaeman-Lim/master
Solve: filterOdd, forEachFilter
2 parents 26d9b49 + d24e472 commit 21bfc53

File tree

10 files changed

+61
-0
lines changed

10 files changed

+61
-0
lines changed

Challenge/JM Lim/filterOdd/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 설명
2+
3+
홀수만 뽑아 배열로 만드세요

Challenge/JM Lim/filterOdd/solve.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const inputArray = [1, 5, 6, 7 ,9, 3, 14];
2+
3+
const answer = inputArray.filter(e => {
4+
return (e%2) == 1
5+
})
6+
7+
console.log(answer);
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 설명
2+
3+
배열 원소중 40 이상인 수만 뽑아 배열을 만드세요.
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const inputArray = [100, 10, 20, 40];
2+
3+
const answer = [];
4+
5+
inputArray.forEach(e => {
6+
e >= 40 ? answer.push(e) : ''
7+
})
8+
9+
console.log(answer);
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)