I have the following code:
var foo = 'foo'
var bar = 'bar'
var arr = [1,2,3]
I want to add to foo
several times at the beginning of the array and bar
at the end of the array. The number of times each element added should be dynamic and the resulting array should be something like:
['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 needed.