function print(max, action){
for(let i = 0; i < max + 1; i++){
action(i);
}
}
function action(i){
console.log(i);
}
function doubleAction(i){
console.log(i * 2);
}
print(5, action); // 0, 1, 2, 3, 4, 5
function print(max, action){
for(let i = 0; i < max + 1; i++){
action(i);
}
}
function doubleAction(i){
console.log(i * 2);
}
print(5, doubleAction); // 0, 2, 4, 6, 8, 10