-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcalcWithFunctions.js
More file actions
28 lines (24 loc) · 918 Bytes
/
calcWithFunctions.js
File metadata and controls
28 lines (24 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function express(num,oper){
if(!oper)
return num
return oper(num);
}
function zero(oper) { return express(0,oper) }
function one(oper) { return express(1,oper) }
function two(oper) { return express(2,oper) }
function three(oper) { return express(3,oper) }
function four(oper) { return express(4,oper) }
function five(oper) { return express(5,oper) }
function six(oper) { return express(6,oper) }
function seven(oper) { return express(7,oper) }
function eight(oper) { return express(8,oper) }
function nine(oper) { return express(9,oper) }
function plus(a) { return function(b) { return b + a } }
function minus(a) { return function(b) { return b - a } }
function times(a) { return function(b) { return b * a } }
function dividedBy(a) { return function(b) { return b / a } }
// - Test Cases -
seven(times(five()))//, 35);
four(plus(nine()))//, 13);
eight(minus(three()))//, 5);
six(dividedBy(two()))//, 3);