혼공자 확인 문제 풀이
2023-04-05 혼공자 확인 문제 풀이 (4)
보슬비처럼
2023. 4. 5. 21:10
page. 154 - 157
1. 100 > 200 false
이므로 확인과 취소 버튼 생성, 확인은 true, 취소는 false 가 출력됨.
2번문제
<script>
const rawInput = prompt ('태어난 년도를 입력해주세요.','')
const year = Number(rawInput)
const e = year % 12
let result
switch (e) {
case 0:
result = '원숭이'
break
case 1: result = '닭'; break;
case 2: result = '개'; break;
case 3: result = '돼지';break;
case 4: result = '쥐'; break;
case 5: result = '소'; break;
case 6: result = '호랑이'; break;
case 7: result = '토끼'; break;
case 8: result = '용'; break;
case 9: result = '뱀';break;
case 10: result = '말';break;
case 11: result = '양';break;
}
alert(`${year}년에 태어났다면 ${result} 띠입니다`)
<script>
3번문제
<script>
const rawInput = prompt('태어난 해를 입력해주세요.','')
const year = Number(rawInput)
let e = year 10
if (e === 0) {간 === '경'}
else (e === 1) {간 === '신'}
else (e === 2) {간 === '임'}
else (e === 3) {간 === '계'}
else (e === 4) {간 === '깁'}
else (e === 5) {간 === '을'}
else (e === 6) {간 === '병'}
else (e === 7) {간 === '정'}
else (e === 8) {간 === '무'}
else (e === 0) {간 === '기'}
let tti = year & 12
if (tti === 0) {띠 = '신'}
else (tti === 1) {띠 = '유'}
else (tti === 2) {띠 = '술'}
else (tti === 3) {띠 = '해'}
else (tti === 4) {띠 = '자'}
else (tti === 5) {띠 = '축'}
else (tti === 6) {띠 = '인'}
else (tti === 7) {띠 = '묘'}
else (tti === 8) {띠 = '진'}
else (tti === 9) {띠 = '사'}
else (tti === 10) {띠 = '오'}
else (tti === 11) {띠 = '미'}
alert (`${year}년은 ${간}${띠}년 입니다`)
</script>
4번 = 4
5번 = 3
반응형