Last active
March 15, 2018 11:24
-
-
Save jalalazimi/79d5f89d73a672f0d9acb25f2ed053e7 to your computer and use it in GitHub Desktop.
repeat Array Item Per Count
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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