[leetcode, JS] 1154. Day of the Year

mxxn·2023년 9월 25일
0

leetcode

목록 보기
84/198

문제

문제 링크 : Day of the Year

풀이

/**
 * @param {string} date
 * @return {number}
 */
var dayOfYear = function(date) {
    return ((new Date(date) - new Date(date.slice(0,4))) + 86400000) / 86400000;
};
  1. new Date로 date와 date의 년도로 날짜의 차이를 계산
  • Runtime 127 ms, Memory 51.3 MB
profile
내일도 글쓰기

0개의 댓글