<script>
const h1 = document.querySelector('h1')
const p = document.querySelector('p')
/*
const isThere = confirm("제목 표시를 할까요?")
if(isThere){
h1.textContent = "문서의 제목!!"
}
*/
if(isThere){
h1.textContent = "당신이 내야 할 버스요금은?"
}
const age = parseInt(prompt("나이가 어떻게 되세요?"))
if(age >= 20){
p.textContent = "1250원입니다!"
}else if(age >= 8){
p.textContent = "760원입니다!"
}else{
p.textContent = "무료입니다!"
}
</script>'오즈코딩스쿨 > [JavaScript]' 카테고리의 다른 글
| 02. Chapter2. 조건문과 반복문 / 7 반복문 while (0) | 2025.09.11 |
|---|---|
| 02.Chapter2. 조건문과 반복문/6 반복문 for (0) | 2025.09.10 |
| 02. Chapter2. 조건문과 반복문/4 비교연산 (0) | 2025.09.10 |
| 02. Chapter2. 조건문과 반복문 / 3 DOM 메소드 및 속성 (0) | 2025.09.10 |