Last active
June 13, 2021 18:04
-
-
Save NickyMeuleman/b3e5d9dd6bb08b6779282f89c3838fed to your computer and use it in GitHub Desktop.
Check if a string contains at least one of a number of different substring options
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 validOptions = ["corgi", "beagle", "dachshund"]; | |
| const string1 = "The labrador jumped"; | |
| const string2 = "The corgi jumped"; | |
| validOptions.some((option) => string1.includes(option)); // false | |
| validOptions.some((option) => string2.includes(option)); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment