Skip to content

Instantly share code, notes, and snippets.

@jalalazimi
Last active March 15, 2018 11:24
Show Gist options
  • Save jalalazimi/79d5f89d73a672f0d9acb25f2ed053e7 to your computer and use it in GitHub Desktop.
Save jalalazimi/79d5f89d73a672f0d9acb25f2ed053e7 to your computer and use it in GitHub Desktop.
repeat Array Item Per Count
// repeatArrayItemPerCount([1,2],2) => [1,1,2,2]
const repeatArrayItemPerCount = (arr, count) => [].concat.apply([], [...arr.reduce((a, v) => [...a, Array(count).fill(v)], [])])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment