Given an array of integers, for example: [1,2,3,4,5]
, I need to be able to take the array and output the array twice. The final result should look like: [1,2,3,4,5,1,2,3,4,5]
. This should be fairly simple, but getting stuck on comma separating the two arrays at the end.
var array = [1,2,3,4,5];
var final = [];
for(i = 1; i <= array.length; i++){
final.push(i);
}
console.log(final+final);
This could also be re-written in a function, so you can pass any number of values, such as function concat(12345){}