Answers for "pentaho remove duplicate values from array"

0

Remove duplicate items in an array

let myArray = ['a', 'b', 'a', 'b', 'c', 'e', 'e', 'c', 'd', 'd', 'd', 'd']
let myOrderedArray = myArray.reduce(function (accumulator, currentValue) {
  if (accumulator.indexOf(currentValue) === -1) {
    accumulator.push(currentValue)
  }
  return accumulator
}, [])

console.log(myOrderedArray)
Posted by: Guest on May-21-2021

Code answers related to "pentaho remove duplicate values from array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language