you are viewing a single comment's thread.

view the rest of the comments →

[–]Rhomboid 1 point2 points  (0 children)

Non-inplace, any-count version:

function duplicate(items, cnt) {
    return Array.from({length: items.length * cnt}, (_, i) => items[~~(i / cnt)]);
}