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