Let's say I "want" 6 elements from an array which only contains 3. If the end is reached, start over.
Example:
let arr = ["a", "b", "c"];
let wanted = 5;
for(let i = 0; i < wanted; i++) {
console.log(arr[i]);
}
Which of course returns:
a
b
c
undefined
undefined
Instead, I need:
a
b
c
a
b
Is there a way to start from the beginning of the array after the elements are over?