Last active
November 10, 2019 07:49
-
-
Save iamshadmirza/b6ed66d93cc6431487c7eb7b209b5b25 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
let food = [ | |
{type: 'beverage', name: 'tea'}, | |
{type: 'veg', name: 'aloo paratha'}, | |
{type: 'non-veg', name: 'biryani'}, | |
{type: 'non-veg', name: 'butter chicken'} | |
]; | |
const filterFunction = (string) => (item) => item.type === string; | |
let nonVegDishes = food.filter(filterFunction('non-veg')); | |
console.log(nonVegDishes); | |
})(); | |
//copy paste in chrome sources |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
function curry(a) { | |
return function multiply(n) { | |
if (n) { | |
a *= n; | |
return multiply; | |
} else { | |
return a; | |
} | |
}; | |
} | |
console.log(curry(2)(2)(2)(2)(2)(2)()); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment