0-2-4-6 à 20

Résolu
Bonjour,

Bonjour,
Je dois faire une fonction en js pour avoir mes numbres paires de 0 à 20 et j'ai du mal à trouver la bonne formule.
Pouvez vous m'aider.

merci par avance.

1 réponse

  1. Bonjour,

    la recherche "is pair javascript" sur google m'a ressorti ceci :

    function isOdd(num) { return num % 2;}
    Note that this will return 0 or 1 (or NaN if you feed it something that isn't a number and can't be coerced into one), which will work fine for most situations.

    Bonne journée
    1. Merci pour ta réponse.