Answers for "duplicate items to form array js"

0

duplicate numbers in an array javascript

[1, 1, 2, 2, 3].filter((element, index, array) => array.indexOf(element) !== index) // [1, 2]
Posted by: Guest on November-10-2020
0

function that duplicates data in array js

function doubleValues(array) {
  var newArray = [];
  array.forEach(function (el) { newArray.push(el, el); });    
  return newArray;
}

console.log(doubleValues([1,2,3]));
Posted by: Guest on April-22-2021

Code answers related to "duplicate items to form array js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language