Skip to content

Instantly share code, notes, and snippets.

@devphenom
Created April 18, 2021 15:47
Show Gist options
  • Save devphenom/ac1dbfd01a3a768bf173be7405bfa4da to your computer and use it in GitHub Desktop.
Save devphenom/ac1dbfd01a3a768bf173be7405bfa4da to your computer and use it in GitHub Desktop.
const removeDuplicateInstances = (arrayList, val) => {
return Array.isArray(arrayList) === false
? "Your first argument must be an array"
: arrayList.length <= 0
? "Your array must contain at least one or more values"
: !val
? "You must pass in the second argument"
: arrayList.filter((index) => index != val).length;
};
console.log(removeDuplicateInstances([5, 2, 2, 5, 3], 5));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment