Created
April 18, 2021 15:47
-
-
Save devphenom/ac1dbfd01a3a768bf173be7405bfa4da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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