- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path7_For_Loop.js
More file actions
Latest commit
26 lines (20 loc) · 637 Bytes
/
Copy path7_For_Loop.js
File metadata and controls
26 lines (20 loc) · 637 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
25
26
/*
Loops: loops are a block of code that are iterated (repeated) until a condition return true
for-loop: a for loop runs only for a finite amount of times.
the strucutre is as follows:
for(initializing statement; test statement; the resultant statment*) {
// some code
}
*/
// Example-1: Incremental loop
for(vari=1;i<=25;i++){
console.log(i)
}
// this code is executed after the loop is finished executing
console.log("GO!");
// Example-2: Decremental loop
for(vari=10;i>0;i--){
console.log(i)
}
// this code is executed after the loop is finished executing
console.log("Happy new year!")