From a5bc3bcc19640b5029dd5697930976864f954330 Mon Sep 17 00:00:00 2001 From: sachinsh01 <89263668+sachinsh01@users.noreply.github.com> Date: Mon, 28 Mar 2022 02:50:08 +0530 Subject: [PATCH 1/4] Create index.html --- index.html | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..ead34c5 --- /dev/null +++ b/index.html @@ -0,0 +1,22 @@ + + + + + + + + Higher Order Functions + + + + +

+

+ Higher Order Functions +

+


+

Open The Console

+

Created by Aniket Artani,Reg - 19BCE10017, FED Squad 106

+ + + From 6b87b8b56bd6c68dc07033ad40584aa619641345 Mon Sep 17 00:00:00 2001 From: sachinsh01 <89263668+sachinsh01@users.noreply.github.com> Date: Mon, 28 Mar 2022 02:50:27 +0530 Subject: [PATCH 2/4] Create app.js --- app.js | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 app.js diff --git a/app.js b/app.js new file mode 100644 index 0000000..42185e9 --- /dev/null +++ b/app.js @@ -0,0 +1,78 @@ +// Array +const foods = ["pizza", "burger", "fingerShips", "donuts", "springRoll"]; + +//#1 Array Slice +function slice_food(foods,x,y) +{ +var modifitem1 = foods.slice(x,y); +console.log(modifitem1); +} +slice_food(foods,1,4); + + +//#2: Array Splice +function splice_food(foods,x,y) +{ + foods.splice(x,y,"noodles","icecream"); + console.log(foods); +} +splice_food(foods,2,0); + + +//#3: Filter +const numberArray= [12,324,213,4,2,3,45,4234]; + let isEven = (numberArray) => { + var even=numberArray.filter(item => { + return item % 2== 0; + }); + console.log(even); +}; +isEven(numberArray); + let prime = (numberArray) =>{ + let p =numberArray.filter(data => { + for(var i=2;i<=Math.sqrt(data);i++) + { + if(data % i == 0) + { + return false; + } + } + return true; + }); + console.log(p); +}; +prime(numberArray); + + +//#4: Reject +function reject(numberArray) +{ + let nonprime = numberArray.filter((number) => + { + for (var i = 2; i <= Math.sqrt(number); i++) + { + if (number % i == 0) + return true; + } + return false; + }); + console.log(nonprime); +} +reject(numberArray); + + +//#5: Lambda +let e = numberArray.filter(data=> data % 2==0); +console.log(e); + + +//#6: Map +const arr1 = [11, 34, 20, 5, 53, 16]; +var newarray =arr1.map(function(data){return data*data;}); +console.log(newarray); + + +//#7: Reduce +var myArray = [2, 3, 5, 10]; +var mul=myArray.reduce(function(i,d){return i*d;}); +console.log(mul); From b70f36a495e4274aa3d6c1aa059d0a90045dd407 Mon Sep 17 00:00:00 2001 From: sachinsh01 <89263668+sachinsh01@users.noreply.github.com> Date: Mon, 28 Mar 2022 02:51:07 +0530 Subject: [PATCH 3/4] Update index.html --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index ead34c5..31e2cec 100644 --- a/index.html +++ b/index.html @@ -16,7 +16,7 @@


Open The Console

-

Created by Aniket Artani,Reg - 19BCE10017, FED Squad 106

+

Created by Sachin Sharma,Reg - 19BAI10082, FED Squad 106

From 332353f720e54bd1f8ce2597018d025f79ea6d5d Mon Sep 17 00:00:00 2001 From: sachinsh01 <89263668+sachinsh01@users.noreply.github.com> Date: Thu, 7 Apr 2022 23:51:47 +0530 Subject: [PATCH 4/4] ProGrad ID : 8731 --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index 42185e9..c8c2744 100644 --- a/app.js +++ b/app.js @@ -74,5 +74,5 @@ console.log(newarray); //#7: Reduce var myArray = [2, 3, 5, 10]; -var mul=myArray.reduce(function(i,d){return i*d;}); +var mul=myArray.reduce(function(i,d){return i*d;}); console.log(mul);