[프로그래머스 lev1/JS] 2016년

woolee의 기록보관소·2022년 11월 8일
0

알고리즘 문제풀이

목록 보기
60/178

문제 출처

프로그래머스 lev1 - 2016년

문제

나의 풀이

Date.prototype.getDay() 하면 0~7 나온다.

function solution(a, b) {
  let day = new Date(2016, a-1, b);
  const WEEKDAY = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'];
  let week = WEEKDAY[day.getDay()];
  return week; 
}

console.log(solution(5, 24));

다른 풀이

function solution(a, b) {
  let day = new Date(2016, a-1, b);
  const WEEKDAY = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'];
  let week = WEEKDAY[day.getDay()];
  return week; 
}

console.log(solution(5, 24));
profile
https://medium.com/@wooleejaan

0개의 댓글