timoxley/functional-javascript-workshop

Trampoline imlementation

KBoiarchuk opened this issue · 0 comments

My trampoline solution:

function repeat(operations, num) {
    var func = operations.bind(null, num);
    trampoline(func, num);
}

function trampoline(fn) {
    for (var i = 0; i < arguments[1]; i++) {
        fn();
    }
}
module.exports = function(operations, num) {
    return repeat(operations, num);
}