Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // joining arrays with dynamic separators.
- // Array::reduce(fn(prev, curr, index, list), initprev)
- [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].reduce(function(prev, curr, key) {
- // prev is the joined section. on the first loop it's ''(initprev).
- return prev +
- (key === 0 ?
- '' :
- ['#', '$', '!', '@', '*'][Math.floor(Math.random() * 5)]
- ) +
- curr
- }, '')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement