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

  • Darren Kitchen

    Darren Kitch

    3 EKİM 2011
  • Distractify

    Distractify

    1 Aralık 2011
  • JamesAtiPhone

    JamesAtiPhon

    16 EYLÜL 2010