Created
October 25, 2018 16:09
-
-
Save alkayesdev/2a41d740fb6f8e8d29c67d857f4c1e54 to your computer and use it in GitHub Desktop.
function generator
This file contains hidden or 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 generate (type){ | |
| if(type==="plus"){ | |
| return (a,b)=>a+b; | |
| } | |
| else if (type=="minus"){ | |
| return (a,b)=>a-b; | |
| } | |
| else if (type === "multiply"){ | |
| return (a,b)=>a*b; | |
| } | |
| else if (type === 'divide'){ | |
| return(a,b)=>a/b | |
| } | |
| } | |
| var x = generate('divide'); | |
| console.log(x(12,6)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment