Skip to content

Instantly share code, notes, and snippets.

@AliceWonderland
Forked from anonymous/7.6 Partial.js
Created April 18, 2017 07:27
Show Gist options
  • Save AliceWonderland/3ce9b63992578c46dc5d78a2612a4aa2 to your computer and use it in GitHub Desktop.
Save AliceWonderland/3ce9b63992578c46dc5d78a2612a4aa2 to your computer and use it in GitHub Desktop.
7.6 Partial created by smillaraaq - https://repl.it/HICV/7
function partial(paramA, paramB){
var resultA=paramA(paramB,0);
var resultB=paramB;
console.log(resultA, resultB);
var resultFunction=function(param){
return resultA+param;
};
return resultFunction;
}
var summer = function(a, b) { return a + b };
var sumFive = partial(summer, 5);
sumFive(10) // => 15;
/* SCHOOL SOLUTION
function partial(fn, arg) {
return function(val) {
return fn(arg, val);
}
}
*/
//did not finish bonus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment