jeudi 25 mars 2021

explain me this code about loop a numbers with if in javaScript

this code for looping a big number of integer if the number Divided by 2 with the string "even" and other integer "odd"

pleas give me a simple explain about it

for(var i=0; i<numbers.length; i++){

    // Let j represents the length of a sub-array 
    for(var j=0; j<numbers[i].length; j++){
        if(numbers[i][j]%2===0)
            numbers[i][j]="even";
        else
            numbers[i][j]="odd";
    }
}

Aucun commentaire:

Enregistrer un commentaire