Skip to content

Commit 8c8fe31

Browse files
committed
while loops
1 parent c8d9453 commit 8c8fe31

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

18_while_loops.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Loops
2+
// repeat run a block of code whilte condition is true
3+
// while loop
4+
// turn on autosave if vcode hangup
5+
6+
// if u declare use const will error cz const can;t change
7+
// const calculate = 10;
8+
9+
// while (calculate == 10) {
10+
// console.log('calculate from : ' + calculate);
11+
// calculate++;
12+
// }
13+
14+
let start = 20;
15+
16+
// while (start >= 10) {
17+
// console.log('print start' + start);
18+
// start++; //false and not execute
19+
// }
20+
21+
// while (start >= 10) {
22+
// console.log('print start' + start);
23+
// start++; //will print looping cz always bigger
24+
// }
25+
26+
// while (start >= 10) {
27+
// console.log('print start ' + start);
28+
// start--; //will print 20 ... 10 why 10, cz >=
29+
// }
30+
31+
// while (start > 10) {
32+
// console.log('print start ' + start);
33+
// start--; //will print 20 ... 11 why 10, cz 10 > 10 is false
34+
// }
35+
36+
while (start < 40) {
37+
console.log(start);
38+
start++; //will print 20 .. 39
39+
}

0 commit comments

Comments
 (0)