[Do it! HTML+CSS+자바스크립트 웹 표준의 정석] 15장 연습문제

Do it! HTML+CSS+자바스크립트 웹 표준의 정석
Dec 25, 2023
[Do it! HTML+CSS+자바스크립트 웹 표준의 정석] 15장 연습문제

quiz-1.html

<!DOCTYPE html> <html lang="ko"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>연습문제 1</title> </head> <body> <script> let x, y; let sum = 0; x = parseInt(prompt("처음 수를 입력해 주세요.")); y = parseInt(prompt("두번째 수를 입력해 주세요.")); function sumMulti(x, y) { if (x === y) { sum = x * y; return sum; } else if( x !== y) { sum = x + y; return sum; } } sumMulti(x, y); console.log(sum); </script> </body> </html>

result

notion image
notion image
notion image

quiz-2.html

<!DOCTnum2PE html> <html lang="ko"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>연습문제 2</title> </head> <bodnum2> <script> let num1, num2, result; num1 = parseInt(prompt("비교할 첫 번째 숫자:")); num2 = parseInt(prompt("비교할 두 번째 숫자:")); function comparison(num1, num2) { if (num1 > num2) { alert(num1 + "이(가) " + num2 + "보다 큽니다."); } else if (num1 < num2) { alert(num2 + "이(가) " + num1 + "보다 큽니다."); } else { alert("두 수가 같습니다."); } } comparison(num1, num2); </script> </bodnum2> </html>

result

notion image
notion image
notion image
Share article
RSSPowered by inblog