title | description | author | tags |
---|---|---|---|
Repeat Function Invocation |
Invokes a function a specified number of times. |
technoph1le |
function,repeat |
const times = (func, n) => {
Array.from(Array(n)).forEach(() => {
func();
});
};
// Usage:
const randomFunction = () => console.log('Function called!');
times(randomFunction, 3); // Logs 'Function called!' three times