Created
October 9, 2020 01:50
-
-
Save farridkun/aea6e68ed33cebaec76ce32157efd55c to your computer and use it in GitHub Desktop.
Ganjil Genap Decision with JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// deklarasi variable & inputan | |
let input = prompt("Masukan angka"); | |
// cek, jika bukan angka & angka >= 0 (tidak minus) | |
if (!isNaN(input) && input >= 0) { | |
// cek, jika angka di modulus2 == 0 | |
if (input % 2 === 0) { | |
// Maka genap | |
alert("Ini adalah genap"); | |
} else { | |
// Maka ganjil | |
alert("Ini adalah ganjil"); | |
} | |
} else { | |
// Input salah | |
alert("Inputan anda salah"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment