Say I have an array :
var newArray = [];
I can add strings to it like so :
var thisString = 'watch';
newArray.push(thisString);
What I want to do is have an array of this string. So, for example, I want newArray to have 50 of these 'thisString'.
I can do this easily via a loop :
for(var i=0;i<50;i++){
newArray.push(thisString);
}
But say if I have 3 strings :
var firstString = 'first', secondString = 'second', thirdString = 'third';
And I want to push the third one 30 times, second 40 times and third 50 times, is the only way of doing this via the loop above ? Or can I say
newArray.push(firstString * 50); //obviously not correct javascript (psuedo code)
I want to do this as in my project I could have over 10 strings. I know this is what loops are built for but I was wondering if there are simpler ways of doing this.
JQuery can be used.