Created
July 29, 2018 15:16
-
-
Save andrelandgraf/3e44a44a7a835462e83035bdd8198195 to your computer and use it in GitHub Desktop.
Using String.prototype.includes() in a case insensitive way
This file contains 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 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