diff --git "a/\354\210\230\354\232\224\354\235\274/MyungHwan/Week04/1.js" "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week04/1.js" new file mode 100644 index 00000000..0291132b --- /dev/null +++ "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week04/1.js" @@ -0,0 +1,8 @@ +function solution(absolutes, signs) { + let result = 0; + for(let i = 0; i < absolutes.length; i++){ + if(signs[i] === false){ + absolutes[i] = absolutes[i] * -1; + }result += absolutes[i] + }return result +} \ No newline at end of file diff --git "a/\354\210\230\354\232\224\354\235\274/MyungHwan/Week04/2.js" "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week04/2.js" new file mode 100644 index 00000000..ea1a4b52 --- /dev/null +++ "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week04/2.js" @@ -0,0 +1,9 @@ +function solution(numbers) { + let result = 0; + + for(let j = 0; j < 10; j++){ + if(!numbers.includes(j)){ + result = result + j + } + }return result +} \ No newline at end of file diff --git "a/\354\210\230\354\232\224\354\235\274/MyungHwan/Week04/3.js" "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week04/3.js" new file mode 100644 index 00000000..957c357b --- /dev/null +++ "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week04/3.js" @@ -0,0 +1,7 @@ +function solution(s) { + let answer = s.length; + + if(answer % 2 === 0){ + return s[(answer/2) - 1] + s[answer/2] + } return s[((answer + 1) / 2) - 1] +} \ No newline at end of file diff --git "a/\354\210\230\354\232\224\354\235\274/MyungHwan/Week04/4.js" "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week04/4.js" new file mode 100644 index 00000000..45679b36 --- /dev/null +++ "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week04/4.js" @@ -0,0 +1,4 @@ +function solution(n) { + let answer = '수박'.repeat(n/2) + return n % 2 === 0 ? answer : answer + '수'; +} \ No newline at end of file diff --git "a/\354\210\230\354\232\224\354\235\274/MyungHwan/Week04/5.js" "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week04/5.js" new file mode 100644 index 00000000..055469c1 --- /dev/null +++ "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week04/5.js" @@ -0,0 +1,4 @@ +function solution(a, b) { + + return a.reduce((acc, cur, idx) => acc += a[idx] * b[idx], 0) +} \ No newline at end of file diff --git "a/\354\210\230\354\232\224\354\235\274/MyungHwan/Week04/6.js" "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week04/6.js" new file mode 100644 index 00000000..8275d701 --- /dev/null +++ "b/\354\210\230\354\232\224\354\235\274/MyungHwan/Week04/6.js" @@ -0,0 +1,3 @@ +function solution(s) { + return s.split("").sort().reverse().join(""); +}