개념
<script>
/*
[요일]
이번 달 1일이 수요일이라고 가정합니다.
1 부터 31 사이의 랜덤 숫자를 저장해 날짜를 구하고,
그 날짜가 무슨 요일인지 출력하시오.
*/
/*
[출력예시]
3
금요일
*/
/*
월 화 수 목 금 토 일
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
*/
let a = Math.floor(Math.random() * 31) + 1;
document.write(a, "<br>");
if(a % 7 == 1) {
document.write("수요일");
}
if(a % 7 == 2) {
document.write("목요일");
}
if(a % 7 == 3) {
document.write("금요일");
}
if(a % 7 == 4) {
document.write("토요일");
}
if(a % 7 == 5) {
document.write("일요일");
}
if(a % 7 == 6) {
document.write("월요일");
}
if(a % 7 == 0) {
document.write("화요일");
}
</script>
HTML
복사