-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloop.js
More file actions
58 lines (50 loc) · 1.09 KB
/
loop.js
File metadata and controls
58 lines (50 loc) · 1.09 KB
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
52
53
54
55
//printing the number from 1 to 100 with interval of 10
for(let i=1;i<=10;i++)
{
console.log(i*10);
}
//printing the number from 10 to 1
for(let i=10;i>0;i--)
{
console.log(i);
}
//printing Multple of 2 untill 10
for(let i=1;i<=10;i++)
{
console.log(i*2);
}
//print the number from 100 to 1 with the difference of 10
for(let i=10;i>0;i--)
{
console.log(i*10);
}
/*function to print the Eligble, Not Eligble voters separately from the list
of array [18,17,16,15,10,8,7,9,35,40,86,75,0]. Note: print invalid if the voter age is 0.
*/
var eligible=[];
var not_eligible=[];
var invalid=[];
//creating a function
function voting(arr)
{
for(let i=0;i<arr.length;i++)
{
if(arr[i]==0)
{
invalid.push(arr[i]);
}
else if(arr[i]>=18)
{
eligible.push(arr[i]);
}
else{
not_eligible.push(arr[i]);
}
}
return {
Eligible_voters:eligible,
Non_Eligible_voters:not_eligible,
invalid_voters:invalid,
}
}
console.log(voting([18,17,16,15,10,8,7,9,35,40,86,75,0]));