I have the following code:
var foo = 'foo'
var bar = 'bar'
var arr = [1,2,3]
I want to add to fooseveral times at the beginning of the array and barat the end of the array. The number of elements added should be dynamic, and the resulting array should look something like this:
['foo','foo',1,2,3,'bar',bar','bar']
Is there a better method than using a loop for each element? I could use lodash if necessary.
source
share