오전
- 개인 과제 리펙토링
RTK를 쓰는 방식에 맞게 코드 수정, 컴포넌트 분리, 날짜별 정렬 등등 코드 리펙토링
오후
- 프로그래머스 문제 풀이
const exchangeCoke = (needCoke, exchangeCoke, myEmptyCoke) => {
const exchangedCoke = Math.floor(myEmptyCoke / needCoke) * exchangeCoke;
const leftoverCoke = myEmptyCoke % needCoke + exchangedCoke;
return [exchangedCoke, leftoverCoke];
}
function solution(a, b, n) {
let answer = 0;
let currentEmptyCoke = n;
while (currentEmptyCoke >= a) {
const [exchangedCoke, leftoverCoke] = exchangeCoke(a, b, currentEmptyCoke);
answer += exchangedCoke;
currentEmptyCoke = leftoverCoke;
}
return answer;
}
function solution(k, score) {
let answer = []
let honor = []
score.forEach((item,idx) => {
honor.push(item)
idx < k -1 ? answer.push(honor.sort((a,b) => b - a)[idx]) : answer.push(honor.sort((a,b) => b - a)[k-1])
})
console.log(answer)
return answer
}
function solution(cards1, cards2, goal) {
for (const item of goal) {
if (cards1.includes(item)) {
if (cards1[0] === item) {
cards1.shift();
} else {
return 'No';
}
} else if (cards2.includes(item)) {
if (cards2[0] === item) {
cards2.shift();
} else {
return 'No';
}
} else {
return 'No';
}
}
return 'Yes';
}
저녁
- Immer.js 학습 예정
- 컴포넌트는 어떻게 분리해야되는가?
블로그에 정리했음