-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloops.html
More file actions
43 lines (41 loc) · 1.28 KB
/
loops.html
File metadata and controls
43 lines (41 loc) · 1.28 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Loops</title>
</head>
<body>
<input type="number" placeholder="Enter any Number" id="punishment-count" />
<button onclick="addPunishment()">Click Me</button>
<div id="punishment"></div>
</body>
<script>
var i = 0;
const container = document.getElementById("punishment");
const count = document.getElementById("punishment-count");
// while (i <= 1) {
// console.log(i);
// i++;
// }
function addPunishment() {
// i = i + 1;
const totalCount = count.value;
// console.log(totalCount);
// var word = `I'll not forget my homework`;
// container.innerHTML += `<div>${word} ${i}</div>`;
printStatements(totalCount);
}
// console.time();
function printStatements(count) {
const container = document.getElementById("punishment");
container.innerHTML = "";
for (var i = 0; i < count; i++) {
var word = `I'll not forget my homework`;
container.innerHTML += `<div>${word} ${i + 1}</div>`;
}
}
// console.timeEnd();
</script>
</html>