-
Notifications
You must be signed in to change notification settings - Fork 0
/
task5.js
116 lines (97 loc) · 1.97 KB
/
task5.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//Activity 1:
function evenodd(a){
if(a%2==0){
console.log("Even");
}
else{
console.log("Odd");
}
}
let a=4;
evenodd(a);
function square(num){
let squ=num*num;
return squ;
}
let num=9;
let result=square(num);
console.log(result);
//Activity 2:
function max(x,y){
if(x>y){
return x;
}
else{
return y;
}
}
let x=9,y=7;
let maximum=max(x,y);
console.log(maximum);
function string(string1,string2,string3){
let full=string1+" "+string2+" "+string3;
return full;
}
let string1="Soham";
let string2="Plays";
let string3="Football";
let fullname=string(string1,string2,string3);
console.log(fullname);
//Activity 3:
let sum=(p,q)=>{
return p+q;
}
let p=5,q=2;
let add=sum(p,q);
console.log(add);
let string=(name)=>{
for(let i in name){
if(i==='S'){
return true;
}
else{
return false;
}
}
}
const checkPresenceOfChar = (str, char) => {
return str.includes(char)?'true':'false';
}
console.log(checkPresenceOfChar("apple", "e"));
//Activity 4:
function product(number1,number2){
return number1*number2;
}
let number1=5,number2=3;
console.log((product(number1,number2)));
function geeting(getting_name,age){
console.log(`Hi ${getting_name} you are ${age} years old`);
}
let getting_name="Soham"
let age=20;
geeting(getting_name,age);
//Activity 5:
function child() {
console.log("This is a child function")
}
function parentFunction(callback, number) {
console.log("This is parent function")
console.log("Child will be called", number, "times")
for (let i = 0; i < number; i++) {
callback()
}
}
parentFunction(child, 5)
function f1(numb) {
console.log("First function is called:")
return numb;
}
function f2(number) {
console.log("Second function print the number", number)
}
function higherOrder2(f1, f2, num) {
// let number = num;
let number = f1(num)
f2(number)
}
higherOrder2(f1, f2, 6)