Skip to content

Instantly share code, notes, and snippets.

@dusanmarsa
Created April 26, 2019 18:40
Show Gist options
  • Save dusanmarsa/b975831fd40bd1e06efe7c4403577014 to your computer and use it in GitHub Desktop.
Save dusanmarsa/b975831fd40bd1e06efe7c4403577014 to your computer and use it in GitHub Desktop.
/*
Loop over array over and over according to its length
*/
let array1 = ['a', 'b', 'c', 'd']
let array2 = [...Array(100)].map((i,o) => o)
let getByIdx = idx => array1[idx - array1.length * (~~(idx / array1.length))])
array2.forEach(getByIdx)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment