-
Notifications
You must be signed in to change notification settings - Fork 0
/
8) JS Functions.js
59 lines (53 loc) · 1.15 KB
/
8) JS Functions.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
52
53
54
55
56
57
58
59
// Set of statement in block to perform some operation
//Types of function pass...
// with parameter without return
function fun(a,b)
{
var even=0;
var odd=0;
console.log("Function");
for(var i=a;i<b;i++)
{
if(i%2==0)
{
console.log(i,"is even");
even++;
}
else
{
console.log(i,"is odd");
odd++;
}
}
console.log("No of even :",even);
console.log("No of odd :",odd);
}
fun(3,13);
console.log();
//with return and with parameter
function fun(a,b)
{
var even=0;
var odd=0;
console.log("Function");
for(var i=a;i<b;i++)
{
if(i%2==0)
{
console.log(i,"is even");
even++;
}
else
{
console.log(i,"is odd");
odd++;
}
}
return [even,odd];
}
var result=fun(3,13);
console.log("No. of even numbers :",result[0]);
console.log("No. of odd numbers :",result[1]);
//TASKS for you ...
// Try for without parameter without return
// Try for without parameter with return