Skip to main content

range

range creates an array starting from 0 with the length of the passed amount. This is a convenient way to generate a sequence of numbers you can map or loop over — for example when rendering a fixed number of placeholder/skeleton elements.

Usage examples

Basic

window.BAO.utils.range(5) // [0, 1, 2, 3, 4]

Rendering placeholders

const skeletons = window.BAO.utils
.range(3)
.map((i) => `<div class="prd-Card prd-Card_Skeleton" data-index="${i}"></div>`)
.join('')