I have an array and I'm looking to create a new array, composed of the original array contents repeated 3 times. For example:
var array = ["red", "green", "blue"];
newArray = ["red red red", "green green green", "blue blue blue"];
My code so far:
var triples = myArray.map(function(){
for (x = 0; x < myArray.length; x++){
return myArray[x].repeat(3);
};
});
console.log(triples);
But this only returns
triples = ["redredred", "redredred", "redredred"];
Any suggestions for a newbie?