Skip to content

Instantly share code, notes, and snippets.

@andrelandgraf
Created July 29, 2018 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrelandgraf/3e44a44a7a835462e83035bdd8198195 to your computer and use it in GitHub Desktop.
Save andrelandgraf/3e44a44a7a835462e83035bdd8198195 to your computer and use it in GitHub Desktop.
Using String.prototype.includes() in a case insensitive way
const myString = "Foo Bar";
const needle = "fOO";
let isCaseInsensitive = myString.includes(needle)); // => isCaseInsensitive is false
isCaseInsensitive = myString.toUpperCase().includes(needle.toUpperCase()); // => isCaseInsensitive is true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment