From 7f21f7f295bd7de2122a9ddf381d8edf507688ea Mon Sep 17 00:00:00 2001 From: Kishan-kumar2020 <67338623+Kishan-kumar2020@users.noreply.github.com> Date: Mon, 20 Jun 2022 20:54:49 +0530 Subject: [PATCH 1/2] Create app.js --- app.js | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 app.js diff --git a/app.js b/app.js new file mode 100644 index 0000000..2267543 --- /dev/null +++ b/app.js @@ -0,0 +1,84 @@ +//Function #1: Array Slice +const foods = ['pizza', 'burger', 'fingerChips', 'donuts', 'springRoll'] + +const slice = foods.slice(1,4); +console.log(slice); + +// Function #2: Array Splice + +const modifiedFood = foods.splice(2,0,'noodles', 'icecream'); +console.log(foods); + +//Function #3: Filter +const numberArray=[9,242,35,67,89,54,1226,80,19]; + +const arr2 = numberArray.filter(function isEven(item) + { + if(item%2==0) + return (item) +}) +console.log(arr2); + +const prime = numberArray.filter(function isPrime(item){ + for(let i=2;i { + let res = numberArray.filter((num) => { + let i = num - 1, + flag = false; + while (i > 1) { + if (num % i == 0) { + flag = true; + break; + } else { + i--; + } + } + if (flag) { + return num; + } + }); + return res; + }; + let newarr = reject(numberArray); + // console.log// Function #4: Reject + + //### Function #5: Lambda + let even = numberArray.filter((num) => num % 2 == 0); + // console.log(even); + + //### Function #6: Map +const myArray = [11, 34, 20, 5, 53, 16]; + +const arr = myArray.map(function findSquareOfNumbers(item){ + return (item*item); + }) + +console.log(arr); + +//### Function #7: Reduce +const myArray1=[2, 3, 5, 10] +const arr1 = myArray1.reduce(function multiply(total,item){ + return total*item +},1) +console.log(arr1) From 864e3728126676b2a4587326eb4e05551dd5abd1 Mon Sep 17 00:00:00 2001 From: Kishan-kumar2020 <67338623+Kishan-kumar2020@users.noreply.github.com> Date: Mon, 20 Jun 2022 20:55:22 +0530 Subject: [PATCH 2/2] Create index.html --- index.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..806c115 --- /dev/null +++ b/index.html @@ -0,0 +1,14 @@ + + + + + + + HOF + + + + + + +