Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
- github pdf
- camera permission
- rolldown
- camera access
- ffi-napi
- device in use
- custom printing
- Can't resolve
- Each child in a list should have a unique "key" prop.
- augmentedDevice
- react-native-dotenv
- nextjs
- Recoil
- Git
- animation
- adb connect
- ELECTRON
- html
- 티스토리 성능
- vercel git lfs
- silent printing
- github 100mb
- electron-packager
- react-native
- 이미지 데이터 타입
- npm package
- Failed to compiled
- github lfs
- dvh
- adb pair
Archives
- Today
- Total
Bleeding edge
[LeetCode] 1185. Day of the Week - 자바스크립트 0623 본문
https://leetcode.com/problems/day-of-the-week/
Day of the Week - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
자바스크립트의 new Date를 이용하여, 요일을 얻고 문제에 주어진 array를 이용하여 요일을 return 하는 문제이다.
단지 문제를 1회차 풀이에서 틀렸었는데 주의를 해야하는 것이
new Date함수이다. new Date함수의 모양을 잘봐보자!
new Date(year, month index, day)
month는 잘보면 month index이다 즉 -1을 해줘야한다!
이전에 써봤었던 new Date인데 막상 문제로 보니 ;ㅁ; 이렇게 사용하는 구나 하고 다시 한번 확인할 수 있었다.
전체 풀이
var dayOfTheWeek = function (day, month, year) {
const dayList = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
return dayList[new Date(year, month - 1, day).getDay()]
};