Created
October 9, 2020 01:48
-
-
Save freyandhy/83c68433b8004319f240d575c19856ea to your computer and use it in GitHub Desktop.
Ini adalah script untuk nge-cek bilangan ganjil & genap
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
// deklrasi variabel & inputan | |
let number = prompt("masukkan angka ?"); | |
// cek, jika bukan number && number >= 0 (tidak minus) | |
if (!isNaN(number) && number >= 0) { | |
// cek, jika number di modulus 2 == 0 | |
if (number % 2 === 0) { | |
console.log("Genap"); // maka genap | |
} else { | |
console.log("Ganjil"); // maka ganjil | |
} | |
} else { // jika inputan salah | |
console.log("Input salah"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
7