-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject_gugudan.html
More file actions
41 lines (38 loc) · 1.04 KB
/
object_gugudan.html
File metadata and controls
41 lines (38 loc) · 1.04 KB
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
39
40
41
<!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>
<h2>객체구구단</h2>
<script>
gugudan = {};
gugudan.result = [];
gugudan.current = -1;
gugudan.calculate = function(n) {
this.current = n;
for (var i = 0; i < 9; i++){
this.result[i] = n * (i + 1);
}
}
gugudan.print = function(){
document.write("<h2>" + this.current + "단</h2>");
for (var i = 0; i < 9; i++){
var x = this.current;
var t = i + 1;
var y = this.result[i];
document.write(x + " * " + t + " = " + y + "<br>");
}
}
function main(){
for (var i =2; i <= 9; i++){
gugudan.calculate(i);
gugudan.print();
}
}
main();
</script>
</body>
</html>