mercredi 24 août 2016

JavaScript IF statement not recognizing variable

I am having a problem with an if statement not recognizing a variables' value

The input is coming from a CSV file, saved to a variable and then passed into this function to check if it is true,

the checkusage console.logs are coming through with the value of "Y" but when ran it seems to keep skipping the checkusage if statement and executes the else statement.

VolumeChargeCalc = function(meterSize, checkusage){
        console.log("Check usage value passed to function is = " + checkusage );
        if(meterSize <= 20) {
            console.log("METER SIZE HAS PASSED");
                if(checkusage == "Y") {
                    console.log("Check usage has been found");
                    return  [0.8042,0.8042,0.6879,0.6627];
                } else {
                    console.log("no check usage found " + checkusage);
                    return  [2.1442,0.8042,0.6879,0.6627];
                } 

        } else if(meterSize == 999){
            return [0.03035,0,0,0];
        } 
        else {
            return [0.8042, 0.8042, 0.6879, 0.6627];
        }
    }

I have tried a few different ways and the all have the same outcome, any ideas would be appreciated.

Aucun commentaire:

Enregistrer un commentaire