Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- Debug
- useEffect
- type
- codewars
- codewar
- custom hook
- descendingOrder
- manifest.json
- react hook
- isSquare
- react
- java api
- TypeScript
- JDBC
- DB2
- TABLESPACE
- IBM
Archives
- Today
- Total
taesik
alpabet war 본문
function alphabetWar(fight) {
let map = { w: -4, p: -3, b: -2, s: -1, m: 4, q: 3, d: 2, z: 1 };
let result = fight.split('').reduce((a, b) => a + (map[b] || 0), 0);
return result ? (result < 0 ? "Left" : "Right") + " side wins!" : "Let's fight again!";
}
The left side letters and their power:
w - 4
p - 3
b - 2
s - 1
The right side letters and their power:
m - 4
q - 3
d - 2
z - 1'functions and trick > typescript_javascript' 카테고리의 다른 글
| how many times father see kid's falling and bouncing ball (0) | 2022.01.25 |
|---|---|
| Write Number in Expanded Form (0) | 2022.01.25 |
| isAscending (0) | 2022.01.25 |
| diamond with * (0) | 2022.01.24 |
| persistence function that takes in a positive parameter num and returns its multiplicative persistence, which is the number of times you must multiply the digits in num until you reach a single digit. (0) | 2022.01.24 |