lundi 5 avril 2021

How to compare not equal value in Array and database fields value in Javascript?

I have this variables getting specific value in loop from database:

var _ID;

for(var x = 0;x<id.length;x++){
    _ID = id[x];
}

Now, I have set array:

var _comID =[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26];

Then I'm comparing this value to _ID in first loop from database(full code below): I have this variables getting specific value in loop from database:

code

var _ID;
var _comID =[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26];


for(var x = 0;x<id.length;x++){
    _ID = id[x];//just to show
     for (z=0;z<_comID.length;z++){
        
        if(_comID[z] == id[x] ){
           console.log(_comID[z]); * //this print the equal value, how ever if not equal can't*
        }
        else{
            console.log(_comID[z]); *// this print all the value from 1 - 26. Please note that the value from  id[x] or _ID are random from 1 - 26 and sometimes its give only 18 to 23 numbers*
          }
    }
}

Aucun commentaire:

Enregistrer un commentaire