mercredi 20 mai 2015

Dynamic if statement in JS

I have a function that looks through arrays and returns ether true or false and will change a global variable to the number that it found if it was above 0. I want to have a if statement that changes so if it is that number it'll call a different function based on that number without having multiple if statements. So something like

if(left == true){
    for(i=1;i<8;i++){
        if(leftnumber == i){
            //function based on i
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire