Here are two if conditions with different checks:
CASE 1:
if(plan_name.indexOf("T1")>=0 && plan_name.indexOf("FLEX")>=0 && plan_name.indexOf("Non-VAE")>=0) {
//do something
}
followed by (in same code/program)
CASE 2:
if(plan_name.indexOf("T1")>=0 && plan_name.indexOf("Non-FLEX")>=0 && plan_name.indexOf("Non-VAE")>=0){
//do something
}
Here is the input to which above conditions get applied:
plan name = iOS 7.7 - RC - T1 - Non-FLEX, Non-VAE
In my code everytime the first if condition in CASE 1 is becoming valid because indexOf() is detecting the substring and not the actual specific string that I want the code to detect(that is CASE 2 should be valid). How to make such specific string match in JS?
FLEXis part ofNon-FLEXand will always match, if you don't want to match, you'll need to add characters, even if those characters are spaces (hint).indexOf(" FLEX")