-
Notifications
You must be signed in to change notification settings - Fork 0
/
18_while_loops.js
39 lines (31 loc) · 894 Bytes
/
18_while_loops.js
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
// Loops
// repeat run a block of code whilte condition is true
// while loop
// turn on autosave if vcode hangup
// if u declare use const will error cz const can;t change
// const calculate = 10;
// while (calculate == 10) {
// console.log('calculate from : ' + calculate);
// calculate++;
// }
let start = 20;
// while (start >= 10) {
// console.log('print start' + start);
// start++; //false and not execute
// }
// while (start >= 10) {
// console.log('print start' + start);
// start++; //will print looping cz always bigger
// }
// while (start >= 10) {
// console.log('print start ' + start);
// start--; //will print 20 ... 10 why 10, cz >=
// }
// while (start > 10) {
// console.log('print start ' + start);
// start--; //will print 20 ... 11 why 10, cz 10 > 10 is false
// }
while (start < 40) {
console.log(start);
start++; //will print 20 .. 39
}