-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnested-loops-2.js
More file actions
43 lines (36 loc) · 1.09 KB
/
Copy pathnested-loops-2.js
File metadata and controls
43 lines (36 loc) · 1.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
// let's practice nested loops a bit more.
// nested loops practice question 1.
for (let a = 1; a <= 5; a++) {
for (let b = 1; b <= a; b++) {
document.write(b);
}
document.write("<br>");
}
// nested loops practice question 2.
for(let a = 1; a <= 5; a++){
for(let b = 1; b <= a; b++){
document.write(a);
}
document.write("<br>");
}
// nested loops practice question 3.
for(let a = 5; a >= 1; a--){
for(let b = 1; b <=a; b++){
document.write(a)
}
document.write("<br>")
}
// nested loops pratice question 4;
for(let a = 5; a >= 1; a--){
for(let b = 1; b <=a; b++){
document.write("*")
}
document.write("<br>")
}
//nested loops practice question 5;
for(let a = 5; a >=1; a--){
for(let b = a; b >=1; b--){
document.write(b);
}
document.write("<br>");
}