Skip to content

Instantly share code, notes, and snippets.

@NickyMeuleman
Last active June 13, 2021 18:04
Show Gist options
  • Select an option

  • Save NickyMeuleman/b3e5d9dd6bb08b6779282f89c3838fed to your computer and use it in GitHub Desktop.

Select an option

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
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