Skip to content

webshrine / stdlib/src / times

Function: times()

times(count, callback): void

Iterates over a given number of times, calling the provided callback function for each iteration.

Parameters

count

number

callback

FnIterateTimes

Returns

void

Example

ts
times(3, (number, index, count) => {
 console.log(`№${number} #${index} of ${count}`)
})
// => '№1 #0 of 3'
// => '№2 #1 of 3'
// => '№3 #2 of 3'

Defined in

packages/stdlib/src/utils/loops.ts:193