lundi 6 novembre 2017

NodeJS: Converting values

Please find the below code;

for(var i=0;i<temp.length;i++){
                    if(obj[temp[i]]!=undefined){
                        if(obj[temp[i]].toUpperCase()=="ON" || obj[temp[i]].toUpperCase()=="LOW"){
                        temp[temp[i]] = 0;
                        temp.timestamp = obj.timestamp;
                        paramCount++;
                    }}}

In above code in [temp[i]] we are passing some Integer values like (34.5,55,45) and some places string like (ON,OFF,on,off),so I have used .toUpperCase() function but its showing error while fetching integer values.

I want that it should take string values like (ON,OFF,on,off) as well as integer. I am New in NODEJS please help for same.

Aucun commentaire:

Enregistrer un commentaire