-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction_gugudan.html
More file actions
38 lines (35 loc) · 1005 Bytes
/
function_gugudan.html
File metadata and controls
38 lines (35 loc) · 1005 Bytes
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
32
33
34
35
36
37
38
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>구구단_함수</title>
</head>
<body>
<h1>구구단_함수</h1>
<script>
function gugudan(x) {
var ret = [];
for (var i = 1; i <= 9; i++){
ret[i] = x * i;
}
return ret;
}
function printResult(x, ret) {
console.log(ret);
document.write("<h2>" + x + "단</h2>");
for (var i = 0; i < (ret.length-1); i++){
document.write(x + " * " + (i+1) + " = " + ret[i+1] + "<br>");
}
}
function main() {
console.log("main 함수가 실행되었습니다.");
for (var n = 2; n <= 9; n++ ){
var result = gugudan(n);
printResult(n, result);
}
}
main();
</script>
</body>
</html>