[프로그래머스 Lv.1] 2016년
function solution(a, b) { const day = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']; return day[new Date(`2016/${a}/${b}`).getDay()]; } // ----- 다른 방법 ----- function solution(a, b) { const month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; const week = ['THU', 'FRI', 'SAT', 'SUN', 'MON', 'TUE', 'WED']; let day = b; for (let i = 0; i < a - 1; i++) day += month[i]; return week[day % 7]; }