jeudi 21 mai 2015

Function to check for substrings

I have a really long list of if statements using this format. I can't figure out a better way to get detect the two substrings, but I know there is one. How can I best improve this if statement, or replace it with a function?

function getCommandCategory() {

if (StTResult.indexOf(categories[0]) >= 1 && StTResult.indexOf(musicParameter[5]) >= 1) {
    openURL();
} 
else if (StTResult.indexOf(categories[0]) >= 1 && StTResult.indexOf(musicParameter[9]) >= 1) {
    openURL2();
}

};

Aucun commentaire:

Enregistrer un commentaire