-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathproblme14.js
51 lines (35 loc) · 778 Bytes
/
problme14.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
40
41
42
43
44
45
46
47
48
49
50
51
/* Task 1. Print the numbers 58 to 98
Task 2. Print all the even numbers between 412 to 456
Task 3. Print all the odd numbers between 581 to 623 */
// Task 1: Print the numbers 58 to 98
/* for( var i = 58; i <= 98; i++){
console.log(i);
} */
// Task 2: Print all the even numbers between 412 to 456
// method a
/* var num = 412;
while ( num <= 456) {
console.log(num);
num+=2;
} */
// method b
var num = 412;
while( num <= 456){
if( num % 2 == 0){
console.log(num);
}
num++;
}
// Task 3: Print all the odd numbers between 581 to 623
// method a
/* for( var i = 581; i <= 623; i+=2){
console.log(i);
}
*/
// method b
for( var i = 581; i <= 623; i++){
if(i % 2 == 0){
continue;
}
console.log(i);
}