Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5936a22

Browse files
solve: 수 조작하기 2
1 parent c5ff514 commit 5936a22

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

‎Level0/PRO181925.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Solution 1
2+
const getCommand = (originalNum, convertedNum) => {
3+
const subtractionOfTwoNumbers = convertedNum - originalNum;
4+
5+
switch (subtractionOfTwoNumbers) {
6+
case 1:
7+
return 'w';
8+
9+
case -1:
10+
return 's';
11+
12+
case 10:
13+
return 'd';
14+
15+
case -10:
16+
return 'a';
17+
}
18+
};
19+
20+
function solution(numLog) {
21+
let commands = '';
22+
23+
for (let i = 0; i < numLog.length - 1; i++) {
24+
commands += getCommand(numLog[i], numLog[i + 1]);
25+
}
26+
27+
return commands;
28+
}

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,3 +283,4 @@
283283
| 23.11.12. | `Level 0` | [조건에 맞게 수열 변환하기 2](https://school.programmers.co.kr/learn/courses/30/lessons/181881) | [JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Level0/PRO181881.js) |
284284
| 23.11.12. | `Level 0` | [배열 만들기 4](https://school.programmers.co.kr/learn/courses/30/lessons/181918) | [JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Level0/PRO181918.js) |
285285
| 23.11.13. | `Level 0` | [영어가 싫어요](https://school.programmers.co.kr/learn/courses/30/lessons/120894) | [JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Level0/PRO120894.js) |
286+
| 23.11.14. | `Level 0` | [수 조작하기 2](https://school.programmers.co.kr/learn/courses/30/lessons/181925) | [JS](https://github.com/JeongHwan-dev/Algorithm-solving-with-js/blob/master/Level0/PRO181925.js) |

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /