diff --git a/func.js b/func.js new file mode 100644 index 0000000..a9e01fe --- /dev/null +++ b/func.js @@ -0,0 +1,92 @@ +function slice() { + const foods = ['pizza','burger','fingerChips','donuts','springRoll','Sandwich','HotDog','Pancake']; + var num1 = parseInt(document.getElementById("n1").value); + var num2 = parseInt(document.getElementById("n2").value); + var modifiedFood = []; + if(num1>=0 && num1<=7 && num2>=1 && num2<=8){ + for(let i=num1;i=0 && num1<=4){ + let i; + for(i=0;i value%2==0); + document.getElementById("out5").innerText = "evennumberArray = ["+res+"]"; + return res; +} + +function findSquare(){ + const myArray = [11, 34, 20, 5, 53, 16]; + let output = myArray.map(function(ele){ + return ele*ele; + }) + document.getElementById("out6").innerText = "SquareofArray = ["+output+"]"; + return output; +} + +function multiply(){ + const myArray = [2, 3, 5, 10]; + let mul = myArray.reduce(function(mul,ele){ + return mul*ele; + },1) + document.getElementById("out7").innerText = "Multiply Value = "+mul; + return mul; +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..87268a7 --- /dev/null +++ b/index.html @@ -0,0 +1,50 @@ + + + + + + + + Higher Order Function + + +

Function 1 : Array Slice()

+

const foods = [pizza, burger, fingerChips, donuts, springRoll, Sandwich, HotDog, Pancake]

+ + + +

+ +

Function 2 : Array Splice()

+

const foods = [pizza, burger, fingerChips, donuts, springRoll]

+ + + +

+ +

Function 3 : Filter()

+

const numberArray = [12,324,213,4,2,3,45,4234]

+ +

+ +

Function 4 : Reject()

+

const numberArray = [12,324,213,4,2,3,45,4234]

+ +

+ +

Function 5 : Lambda()

+

const numberArray = [12,324,213,4,2,3,45,4234]

+ +

+ +

Function 6 : Map()

+

const myArray = [11, 34, 20, 5, 53, 16]

+ +

+ +

Function 7 : Reduce()

+

const myArray = [2, 3, 5, 10]

+ +

+ +