Here, we make a new version of log that only does something if its argument is positive. We do this by wrapping the original log function. And we do that by using callIfPositive to construct a new function that calls the original function (its argument) when the new function receives a positive value.

Results

function callIfPositive(fn) {
    return function(x) {
        return x > 0 ? fn(x) : undefined;
    }
}
var logIfPositive = callIfPositive(log);
for (var i = -5; i < 5; i++) logIfPositive(i);