-
Notifications
You must be signed in to change notification settings - Fork 114
solved: everyArray, expDivOdd, filterAge, filterIntersection #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # 문제제목 | ||
|
|
||
| ## 설명 | ||
|
|
||
| every를 이용해서 모든 원소가 짝수인지 아닌지를 판별하세요 | ||
|
|
||
| ## Expected Output | ||
|
|
||
| true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| function solution(inputArray) { | ||
| return inputArray.every((i) => i % 2 === 0); | ||
| } | ||
|
|
||
| const inputArray = [2, 4, 6, 8, 10]; | ||
|
|
||
| // const inputArray2 = [2, 3, 6, 8, 10]; | ||
| // console.log(solution(inputArray2)); | ||
| // exports.solution = solution; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| const { solution } = require("./solve"); | ||
|
|
||
| const test1 = { | ||
| input: [2, 4, 6, 8, 10], | ||
| answer: true, | ||
| }; | ||
|
|
||
| const test2 = { | ||
| input: [2, 3, 6, 8, 10], | ||
| answer: false, | ||
| }; | ||
|
|
||
| describe("everyArray", () => { | ||
| test("모두 짝수면 true여야 한다.", () => { | ||
| expect(solution(test1.input)).toEqual(test1.answer); | ||
| }); | ||
|
|
||
| test("홀수가 있으면 false여야 한다.", () => { | ||
| expect(solution(test2.input)).toEqual(test2.answer); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ## 설명 | ||
|
|
||
| 제곱한 후 3으로 나눈 나머지가 홀수인 것 을 뽑은 배열의 총 합을 구하세요. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // ## 설명 | ||
|
|
||
| // 제곱한 후 3으로 나눈 나머지가 홀수인 것 을 뽑은 배열의 총 합을 구하세요. | ||
|
|
||
| function solution(inputArray) { | ||
| return inputArray | ||
| .map((i) => i * i) | ||
| .filter((i) => i % 3 === 1) | ||
| .reduce((acc, i) => acc + i); | ||
| } | ||
| exports.solution = solution; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| const { solution } = require('./solve'); | ||
|
|
||
| const test1 = { | ||
| input: [1, 7, 3, 4, 6], | ||
| answer: 66, | ||
| }; | ||
|
|
||
| const test2 = { | ||
| input: [2, 3, 6, 8, 10], | ||
| answer: 168, | ||
| }; | ||
|
|
||
| describe('everyArray', () => { | ||
| test('1, 7, 3, 4, 6', () => { | ||
| expect(solution(test1.input)).toEqual(test1.answer); | ||
| }); | ||
|
|
||
| test('2, 3, 6, 8, 10', () => { | ||
| expect(solution(test2.input)).toEqual(test2.answer); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ## 설명 | ||
|
|
||
| 배열 원소의 age가 30이상 50미만인 사람만 있는 객체의 배열을 만드세요 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // write your codes | ||
| // const input = [ | ||
| // { | ||
| // name: "영미", | ||
| // age: 25, | ||
| // }, | ||
| // { | ||
| // name: "일미", | ||
| // age: 35, | ||
| // }, | ||
| // { | ||
| // name: "이미", | ||
| // age: 45, | ||
| // }, | ||
| // { | ||
| // name: "삼미", | ||
| // age: 55, | ||
| // }, | ||
| // ]; | ||
| function solution(inputArray) { | ||
| return inputArray.filter((i) => i.age >= 30 && i.age < 50); | ||
| } | ||
|
|
||
| exports.solution = solution; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| const { solution } = require('./solve'); | ||
|
|
||
| const test1 = { | ||
| input: [ | ||
| { | ||
| name: '영미', | ||
| age: 25, | ||
| }, | ||
| { | ||
| name: '일미', | ||
| age: 35, | ||
| }, | ||
| { | ||
| name: '이미', | ||
| age: 45, | ||
| }, | ||
| { | ||
| name: '삼미', | ||
| age: 55, | ||
| }, | ||
| ], | ||
| answer: [ | ||
| { name: '일미', age: 35 }, | ||
| { name: '이미', age: 45 }, | ||
| ], | ||
| }; | ||
|
|
||
| describe('filterAge', () => { | ||
| test('test1', () => { | ||
| expect(solution(test1.input)).toEqual(test1.answer); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # 문제제목 | ||
|
|
||
| ## 설명 | ||
|
|
||
| 두 배열의 교집합을 출력하세요! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // const A = [1, 2, 3, 4, 5]; | ||
| // const B = [3, 4, 5, 6, 7]; | ||
|
|
||
| function solution(inputArray1, inputArray2) { | ||
| return inputArray1.filter((i) => inputArray2.includes(i)); | ||
| } | ||
|
|
||
| exports.solution = solution; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| const { solution } = require('./solve'); | ||
|
|
||
| const test1 = { | ||
| input: { | ||
| A: [1, 2, 3, 4, 5], | ||
| B: [3, 4, 5, 6, 7], | ||
| }, | ||
| answer: [3, 4, 5], | ||
| }; | ||
|
|
||
| describe('filterIntersection', () => { | ||
| test('test1', () => { | ||
| expect(solution(test1.input.A, test1.input.B)).toEqual(test1.answer); | ||
| }); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 solution export 하는 건 주석풀어야합니다~!