mercredi 18 avril 2018

Function returns false everytime

I have a simple function that have If else statements. It takes two arguments a and b. But it always return last end statement not want I wanted.

I tried all the selectby() choices. But every time it returns 100. How can I fix this? I will be happy if I learn that. Thanks.

function selectby(a,b)
{
    if(a==5 && b==5)
    return 0;
    else if(a==6 && b==5)
    return 1;
    else if(a==7 && b==5)
    return 2;
    else if(a==5 && b==6)
    return 3;
    else if(a==6 && b==6)
    return 4;
    else if(a==7 && b==6)
    return 5;
    else if(a==5 && b==7)
    return 6;
    else if(a==6 && b==5)
    return 7;
    else if(a==7 && b==5)
    return 8;
    else return 100;
}

Aucun commentaire:

Enregistrer un commentaire