몇주
![[JS] getWeek(), 특정 날짜가 몇주차인지 구하기](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FKXJd5%2FbtrRJO7A7jf%2Fw9kyc7yJV7SvA9mB3Nm2Ok%2Fimg.jpg)
[JS] getWeek(), 특정 날짜가 몇주차인지 구하기
코드 const getWeek = (date) => { const currentDate = date.getDate(); const firstDay = new Date(date.setDate(1)).getDay(); return Math.ceil((currentDate + firstDay) / 7); }; const week = getWeek(new Date("2022-11-11")); console.log(week + "주차"); // 2주차 2022-11-11와 같은 Date 객체를 넘길 시, 해당 날짜가 위치한 주차를 구해서 반환해주는 함수입니다. 코드 풀이 const date = new Date('2022-11-11'); const currentDate = date.getDate(); // 11 c..