Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- написать калькулятор вида five(pluc(one())) // 6
- */
- function five(fn) {
- if (fn) return fn(5);
- return 5;
- }
- function one(fn) {
- if (fn) return fn(1);
- return 1;
- }
- function two(fn) {
- if (fn) return fn(2);
- return 2;
- }
- function seven(fn) {
- if (fn) return fn(7);
- return 7;
- }
- function add(val) {
- return function(v) {
- return v + val;
- }
- }
- function subtract(val) {
- return function(v) {
- return v - val;
- }
- }
- console.log('---calculator---')
- console.log(five(add(one())));
- console.log(seven(subtract(two())))
- console.log('----------------')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement