How to check occurrence of a substring in a case insensitive?

How to check occurrence of a substring in a case insensitive?

let = "John"
let result = value.indexOf(text);

In this case it will return the index of the substring only in the case of the row, if Ivan will be written with a capital letter. And how to do it with a little determined?
March 19th 20 at 09:04
3 answers
March 19th 20 at 09:06
Solution
value.toLowerCase().indexOf(text.toLowerCase())
March 19th 20 at 09:08
Solution
let value = "John";
let text = "IV";
let result = (value.toLowerCase().indexOf(text.toLowerCase()) !== -1); // true
March 19th 20 at 09:10
Solution
Regular expressions
Their flags

let result = /Ivan/i.test(value);
if you need the index:
let result = value.match(/Ivan/i).index;

Find more questions by tags JavaScript