Skip to content

Instantly share code, notes, and snippets.

@KyleMit
Created October 26, 2020 15:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KyleMit/9719f5e5c2498a571248be6f7fbdaaba to your computer and use it in GitHub Desktop.
Save KyleMit/9719f5e5c2498a571248be6f7fbdaaba to your computer and use it in GitHub Desktop.
Twitter - Variadic Function
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