Función de repetición personalizada de JavaScript
/* Build a custom repeat function: perform an action "n" times. */
repeat = (n, action) => {
for (let i = 0; i < n; i++) {
action(i);
}
}
repeat(5, n => {
console.log(2 * n);
});
// → 0 2 4 6 8
Intra