Is there a way to achieve the same result as this code snippet without utilizing a for loop?
Currently unsure about which array method would be appropriate
function duplicateElements(x){
var y = [];
x.forEach(element =>{
y.push(element);
y.push(element);
});
return y;
}
var inputArray = [1,2,3,4,5,6];
console.log(duplicateElements(inputArray));// returns [1,1,2,2,3,3,4,4,5,5,6,6]