-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlecture9.html
37 lines (30 loc) · 964 Bytes
/
lecture9.html
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
<!doctype html>
<html>
<head>
<title>Using while loops</title>
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css">
</style>
</head>
<body>
<script type="text/javascript">
var freeSpaceInContainer = 30;
var numberOfCars = 1;
// load container with cars until it is fully loaded (while loop)
while (numberOfCars <= freeSpaceInContainer) {
console.log("Added one more car to the container.");
numberOfCars++;
}
console.log("Container fully loaded.");
numberOfCars = 1;
// load container with cars until it is fully loaded (do-while loop)
do {
console.log("Added one more car to the container.");
numberOfCars++;
} while (numberOfCars <= freeSpaceInContainer);
console.log("Container fully loaded.");
</script>
</body>
</html>