Created
July 3, 2019 03:45
-
-
Save Kkan9ma/91b3ea469e4f92a3329bd5ba1975cbe8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>구구단 연습</title> | |
</head> | |
<body> | |
<h1>구구단 연습하기</h1> | |
<script> | |
var n = Number(prompt("몇 단을 출력할까요?")) | |
// 원하는 값이 있으면 var n = x; | |
if (n >= 2 && n <= 9) { | |
var i = 1; | |
while(i <= 9) { | |
document.write(n + " * " + i + " = " + (n * i) + "<br>"); | |
console.log(n + " * " + i + " = " + (n * i)); | |
i++; | |
} | |
} else { | |
document.write("2 이상, 9 이하의 값만 입력할 수 있습니다."); | |
console.log("2 이상, 9 이하의 값만 입력할 수 있습니다."); | |
} | |
// for (var i = 1; i <= 9; i++) { | |
// document.write(n + " * " + i + " = " + (n * i) + "<br>"); | |
// console.log(n + " * " + i + " = " + (n * i)); | |
// } else { | |
// document.write("2 이상, 9 이하의 값만 입력할 수 있습니다."); | |
// console.log("2 이상, 9 이하의 값만 입력할 수 있습니다."); | |
// } | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment