I have a variable activeUserName and a variable manager1.
How can I check if activeUserName contains at least three characters, that are in manager1? (The position of those characters doesn't matter)
For example in the following case, it should return true, because the characters 'J', 'o' and 'e' are inside manager1.
var activeUserName = "JohnDoe100";
var manager1 = "JYZALoe999";
Right now I'm using the indexOf method and only look at characters in certain positions which is why I want to change that:
if (isEditor == false){
if (((activeUserName.indexOf(manager1.charAt(0)) !== -1) && (activeUserName.indexOf(manager1.charAt(2)) !== -1)) || (activeUserName.indexOf(manager1.charAt(4)) !== -1)){
// doSth();
} else if (((activeUserName.indexOf(manager2.charAt(0)) !== -1) && (activeUserName.indexOf(manager2.charAt(2)) !== -1)) || (activeUserName.indexOf(manager2.charAt(4)) !== -1)){
// doSth();
} else {
// doSth();
}
}
I read about Regex, but I'm not sure if this can be applied here.
Any help is appreciated!