- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path8_While_Loop.js
More file actions
Latest commit
24 lines (18 loc) · 612 Bytes
/
Copy path8_While_Loop.js
File metadata and controls
24 lines (18 loc) · 612 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*
Loops: loops are a block of code that are iterated (repeated) until a condition return true
while-loop: a for loop runs only for a finite amount of times.
the strucutre is as follows:
while(condition){
//some code
}
*/
// this variable will be used to end the loop after some time
varcounter=10
// this loop until the value of the counter is not less than or equal to '0'
while(counter>=0){
// prints the value for counter
console.log(counter)
// decrement the value for counter each time the loop is run
counter--
}
console.log("While Loop ended!");