Created
October 26, 2020 15:49
-
-
Save KyleMit/9719f5e5c2498a571248be6f7fbdaaba to your computer and use it in GitHub Desktop.
Twitter - Variadic Function
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
let checkValInList = (val, ignoreCase, ...list) => { | |
return ignoreCase | |
? list.some(el => el.toLowerCase() === val.toLowerCase()) | |
: list.includes(val) | |
} | |
checkValInList("hello", true, "Hi", "Hello", "Howdy") // true | |
checkValInList("hello", false, "Hi", "Hello", "Howdy") // false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment