arr = [1, 2, 3, 4]; function pairwise(arr, func){ for(var i=0; i < arr.length - 1; i++){ func(arr[i], arr[i + 1]) } } pairwise(arr, function(current, next){ console.log(current, next) })