What would be the equivalent of this without using a for loop?
Unsure what array method to use
function func(x){
var y = [];
for(i=0;i<x.length;i++){
y.push(x[i]);
y.push(x[i]);
}
return y;
}
var input = [1,2,3,4,5,6];
console.log(func(input));// returns [1,1,2,2,3,3,4,4,5,5,6,6]
.map()and a study of any basic description of how.map()works or even looking at how the MDN polyfill works would have shown you that there is no way to achieve this with.map(). And, then you go and seem to like two answers that don't solve it with.map()alone. It seems like you're really just asking for a cleaner way to accomplish your goal and should remove the.map()part from your question since it's a non-starter and apparently not a requirement either.