-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfizzbuzz.html
More file actions
48 lines (42 loc) · 1.03 KB
/
fizzbuzz.html
File metadata and controls
48 lines (42 loc) · 1.03 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
42
43
44
45
46
47
48
<!DOCTYPE html>
<html>
<head>
<title>fizz buzz</title>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
<body>
<div id="div1">
</div>
<script>
var para;
var node;
var element = document.getElementById("div1");
for(var i= 1; i<101; i++){
if((i % 3 === 0) &&(i % 5 === 0)){
para = document.createElement("p");
para.classList.add("fizzbuzz");
node = document.createTextNode("fizzbuzz");
para.appendChild(node);
element.appendChild(para);
}else if(i % 5 === 0){
para = document.createElement("p");
para.classList.add("buzz");
node = document.createTextNode("buzz");
para.appendChild(node);
element.appendChild(para);
}else if(i % 3 === 0){
para = document.createElement("p");
para.classList.add("fizz");
node = document.createTextNode("fizz");
para.appendChild(node);
element.appendChild(para);
}else{
para = document.createElement("p");
node = document.createTextNode(i);
para.appendChild(node);
element.appendChild(para);
}
}
</script>
</body>
</html>