There is a need to compare two lines without case. For example, there are two lines "ivanovii" and "IvanovII" , formally, this is the same thing. It can also be like this: "Ivanovii" and "IvanovII" . In general, you need to somehow compare the string without considering the register, how can this be done?
|
1 answer
Bring them to the same case.
Strings have methods toUpperCase () , toLowerCase () ;
var myStr = 'приветики', mySecondStr = 'ПрИвЕтИкИ'; console.log(myStr.toUpperCase() === mySecondStr.toUpperCase()); |
str.ToUpperCaselines and then compare them with each other. - BlackWitcher