https://programmers.co.kr/learn/courses/30/lessons/12901
다른 사람의 풀이 => new Date()
이용
2020
function solution(a, b) {
var answer = '';
var day = ["THU","FRI","SAT","SUN","MON","TUE","WED"];
var days = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
var sumToLastMonth = 0;
var totalDays = 0;
var target = '';
for(var i=0; i<a-1; i++){
sumToLastMonth = sumToLastMonth + days[i];
}
totalDays = sumToLastMonth + b;
target = totalDays%7;
answer = day[target];
return answer;
}
function solution(a, b) {
var answer = '';
var daysOfMonth = [31,29,31,30,31,30,31,31,30,31,30,31];
var dayOfWeek = ['THU','FRI','SAT','SUN','MON','TUE','WED'];
var days = 0;
var finalDays = 0;
for (var i = 0; i < (a-1); i++){
days = days + daysOfMonth[i];
}
finalDays = days + b;
var result = finalDays % 7;//0~6
answer = dayOfWeek[result];
return answer;
}
// 무슨 요일인가? - a월 b일을 숫자로 치환
// 1 31 2 29 3 31 4 30 5 31 6 30 731 831 9 30 10 31 11 30 12 31
//