Created
April 3, 2020 18:29
-
-
Save ricealexander/9e74f43d6aafed8f8e44942dd87c36b4 to your computer and use it in GitHub Desktop.
Compares strings to determine whether they are all the same, case-insensitively
This file contains hidden or 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 matchesCaseInsensitive = (first, ...rest) => { | |
if (rest.length === 0) { | |
throw new Error(`Expected at least 2 arguments`) | |
} | |
const target = first.toLowerCase() | |
return rest.every(value => value.toLowerCase() === target) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment