SORU
16 ŞUBAT 2011, ÇARŞAMBA


Nasıl bir dizi JavaScript tek olup olmadığını belirlemek için

Eğer JavaScript çift veya tek bir sayı olup olmadığını belirlemek için bazı kod için beni işaret edebilir?

CEVAP
16 ŞUBAT 2011, ÇARŞAMBA


function isOdd(num) { return num % 2;}
console.log("1 is odd "   isOdd(1) == true);
console.log("2 is odd "   isOdd(2) == false);
console.log("3 is odd "   isOdd(3) == true);
console.log("4 is odd "   isOdd(4) == false);

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • andyabc45

    andyabc45

    1 Mayıs 2011
  • LearnKey

    LearnKey

    19 AĞUSTOS 2008
  • Tire Rack

    Tire Rack

    31 Mayıs 2007