-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11. Function Arithmetic.js
More file actions
58 lines (40 loc) · 1.02 KB
/
11. Function Arithmetic.js
File metadata and controls
58 lines (40 loc) · 1.02 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
56
57
58
// Sum
function sum(a,b){
return a+b
}
result=sum(10,5)
console.log("Sum of a and b is ",result)
// Substract
function sub(a,b){
return a-b
}
result=sub(10,5)
console.log("Sub of a and b is ",result)
// Division
function div(a,b){
return a/b
}
result=div(10,5)
console.log("Div of a and b is ",result)
// Multiply
function mul(a,b){
return a*b
}
result=mul(10,5)
console.log("Mul of a and b is ",result)
function rem(a,b){
return a%b
}
result=rem(10,5)
console.log("Rem of a and b is ",result)
function sum(a,b, c=3){ //here c is 3 const declared
return a+b+c
}
result1=sum(10,5) //if not declaring sum as var (result) then output is undefined
result2=sum(10,4)
result3=sum(10,3)
result4=sum(10,2,1) //value of c is changed as 1
console.log("Sum of a and b is ",result1)
console.log("Sum of a and b is ",result2)
console.log("Sum of a and b is ",result3)
console.log("Sum of a and b is ",result4)