DEV Community

Cover image for Js repeat a function by for loop
JAHID
JAHID

Posted on

Js repeat a function by for loop

Syntex:

const hi = function () {
 console.log('Hi! You Are Welcome !!');
};
function repeat(func, num) {
 for (let i = 0; i < num; i++) {
 func();
 }
}
repeat(hi, 2);

Top comments (0)