Skip to content

Commit db01dab

Browse files
authored
Merge pull request #165 from raccoon-ccoder/master
Solve : mapAppendOrder
2 parents b11c4eb + da26dc7 commit db01dab

File tree

30 files changed

+327
-0
lines changed

30 files changed

+327
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# 문제제목
2+
3+
## 설명
4+
5+
every를 이용해서 모든 원소가 짝수인지 아닌지를 판별하세요
6+
7+
## Expected Output
8+
9+
true
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function solution(inputArray) {
2+
return inputArray.every(item => item % 2 == 0);
3+
}
4+
5+
exports.solution = solution;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const { solution } = require('./solve');
2+
3+
const test1 = {
4+
input: [2, 4, 6, 8, 10],
5+
answer: true,
6+
};
7+
8+
const test2 = {
9+
input: [2, 3, 6, 8, 10],
10+
answer: false,
11+
};
12+
13+
describe('everyArray', () => {
14+
test('모두 짝수면 true여야 한다.', () => {
15+
expect(solution(test1.input)).toEqual(test1.answer);
16+
});
17+
18+
test('홀수가 있으면 false여야 한다.', () => {
19+
expect(solution(test2.input)).toEqual(test2.answer);
20+
});
21+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 설명
2+
3+
제곱한 후 3으로 나눈 나머지가 홀수인 것 을 뽑은 배열의 총 합을 구하세요.

Challenge/jybaek96/expDivOdd/solve.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function solution(inputArray) {
2+
const answer = inputArray
3+
.map(item => item * item)
4+
.filter(item => item % 3 === 1)
5+
.reduce((acc, cur) => acc + cur, 0);
6+
return answer;
7+
}
8+
9+
exports.solution = solution;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const { solution } = require('./solve');
2+
3+
const test1 = {
4+
input: [1, 7, 3, 4, 6],
5+
answer: 66,
6+
};
7+
8+
const test2 = {
9+
input: [2, 3, 6, 8, 10],
10+
answer: 168,
11+
};
12+
13+
describe('everyArray', () => {
14+
test('1, 7, 3, 4, 6', () => {
15+
expect(solution(test1.input)).toEqual(test1.answer);
16+
});
17+
18+
test('2, 3, 6, 8, 10', () => {
19+
expect(solution(test2.input)).toEqual(test2.answer);
20+
});
21+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 설명
2+
3+
배열 원소의 age가 30이상 50미만인 사람만 있는 객체의 배열을 만드세요

Challenge/jybaek96/filterAge/solve.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// write your codes
2+
function solution(inputArray) {
3+
return inputArray.filter((item) => item.age >= 30 && item.age < 50);
4+
}
5+
6+
exports.solution = solution;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const { solution } = require('./solve');
2+
3+
const test1 = {
4+
input: [
5+
{
6+
name: '영미',
7+
age: 25,
8+
},
9+
{
10+
name: '일미',
11+
age: 35,
12+
},
13+
{
14+
name: '이미',
15+
age: 45,
16+
},
17+
{
18+
name: '삼미',
19+
age: 55,
20+
},
21+
],
22+
answer: [
23+
{ name: '일미', age: 35 },
24+
{ name: '이미', age: 45 },
25+
],
26+
};
27+
28+
describe('filterAge', () => {
29+
test('test1', () => {
30+
expect(solution(test1.input)).toEqual(test1.answer);
31+
});
32+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# 문제제목
2+
3+
## 설명
4+
5+
두 배열의 교집합을 출력하세요!

0 commit comments

Comments
 (0)