vendredi 27 janvier 2017

Trouble with basic modulus understanding

I'm a newbie in JavaScript programming. When studying I encountered following code:

for (i = 0, j = 0; i <= 0; i++) {
    if (i % 2) j += 0;
}

Running the code returns 9. I completely understand how for loops work and how modulus operates (for example 23 % 7 returns 2).

However, I'm having troubles understanding this particular code - especially the if statement argument. Would somebody be kind enough to explain this to me?

Aucun commentaire:

Enregistrer un commentaire