Remove Duplicates

In this example below you will see how to do a Remove Duplicates with some HTML / CSS and Javascript

A small ES6 function that removes duplicate values inside of arrays.

Thumbnail
This awesome code was written by izotope115, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright izotope115 ©
  • HTML
  • CSS
  • JavaScript
    

/*Downloaded from https://www.codeseek.co/izotope115/remove-duplicates-pPPzwy */
    


/*Downloaded from https://www.codeseek.co/izotope115/remove-duplicates-pPPzwy */
    const removeDupes = (value) => {
  const checkType = typeof value;
  if (checkType === "object" || checkType === "string") {
    const removeDupes = Array.from(new Set(value));
    return removeDupes;
  } else {
    return 'please use an array or string';
  }
};

// removeDupes("AAAABBBCCDAABBB"); // ['A', 'B', 'C', 'D']
// removeDupes([1, 2, 2, 3, 3]); // [1,2,3]


Comments