From 756d7c1714ca3bf13871ea7b2db53c5eeb66fa64 Mon Sep 17 00:00:00 2001 From: Shreshth Jaiswal <67462416+shreshth02@users.noreply.github.com> Date: Mon, 28 Mar 2022 10:25:07 +0530 Subject: [PATCH 1/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 513944a3d17cd1a8e634cd6d13b2c2a3d39e9c9c Mon Sep 17 00:00:00 2001 From: Shreshth Jaiswal <67462416+shreshth02@users.noreply.github.com> Date: Mon, 28 Mar 2022 10:26:06 +0530 Subject: [PATCH 2/4] Create index.html --- index.html | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..ed43e09 --- /dev/null +++ b/index.html @@ -0,0 +1,21 @@ + + + + + + + Higher Order Functions + + + + +

+

+ Higher Order Functions +

+


+

Open The Console

+

Created by Shreshth Jaiswal,Reg - 19BCE10092, FED Squad 106

+ + + From 955b645d22e4431f32a99f8b016f56ed0b92f65c Mon Sep 17 00:00:00 2001 From: Shreshth Jaiswal <67462416+shreshth02@users.noreply.github.com> Date: Fri, 8 Apr 2022 09:38:03 +0530 Subject: [PATCH 3/4] Prograd ID : 8730 --- app.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app.js b/app.js index 42185e9..9479d0f 100644 --- a/app.js +++ b/app.js @@ -76,3 +76,4 @@ console.log(newarray); var myArray = [2, 3, 5, 10]; var mul=myArray.reduce(function(i,d){return i*d;}); console.log(mul); + From bc40adfe57818de5b0032eaf87e86bdbc04d1973 Mon Sep 17 00:00:00 2001 From: Shreshth Jaiswal <67462416+shreshth02@users.noreply.github.com> Date: Fri, 8 Apr 2022 09:38:38 +0530 Subject: [PATCH 4/4] Prograd ID : 8730 --- index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/index.html b/index.html index ed43e09..862c2d4 100644 --- a/index.html +++ b/index.html @@ -19,3 +19,4 @@

+