-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathloopsAssignment.html
More file actions
61 lines (60 loc) · 2.09 KB
/
loopsAssignment.html
File metadata and controls
61 lines (60 loc) · 2.09 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
49
50
51
52
53
54
55
56
57
58
59
60
61
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>WDV221 Intro Javascript - Loops</title>
</head>
<body onload="select()">
<h1>WDV221 Intro Javascript</h1>
<h2>Project-5 Loops Assignment</h2>
<hr />
<p>Please complete the following exercises on this page. When complete post this page to your server. Make a link in your WDV221 homework page for this assignment. </p>
<p>Include a comment in each script with the exercise number and a description of what the script is supposed to do.</p>
<p>Using Blackboard submit this Assignment.</p>
<hr />
<h3>Instructions: </h3>
<p>Please complete the following exercises using Javascript loops as indicated. Please place your code on this page. Use runtime scripts unless told otherwise. </p>
<p>1. Create a WHILE loop that will print out the numbers 0 to 4 each on a seperate line.</p>
<script>
let index = 0;
while (index <= 4) {
document.write(index + "<br/>");
index++;
}
</script>
<p>2. Create a FOR loop that will print out the numbers 4 to 0 each on a seperate line.</p>
<script>
for (let index = 4; index >= 0; index--) {
document.write(index + "<br/>");
}
</script>
<p>3. Create a loop that will print 1 to 5 each in its own paragraph element.</p>
<script>
for (let index = 1; index <= 5; index++) {
document.write("<p>"+ index + "</p>");
}
</script>
<p>4. Create a loop that will print out the following numbers (5,10,15,20,25...) until one is greater than 40.</p>
<script>
for (let index = 5; index <= 40; index = index + 5) {
document.write(index + "<br/>")
}
</script>
<p>5. Create a loop that will print out 6 of the following messages (Option 1, Option 2, Option 3, etc. ) as options within the drop down menu below.</p>
<script>
function select(){
let option = document.getElementById("select");
for (let index = 1; index <= 6; index++) {
option.innerHTML += "<option> Option" + index + "</option>"
}
}
</script>
<p>
<label>Select an Option!
<select name="select" id="select">
</select>
</label>
</p>
<p> </p>
</body>
</html>