Javascript : Pernyataan IF
Pernyataan IF
7. Script :
<HTML>
<HEAD>
<TITLE>Contoh if</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE = "JavaScript">
var nilai = prompt("Nilai (0-100): ", 0);
var hasil = "Tidak Lulus";
if (nilai >= 60)
hasil = "Lulus";
document.write("Hasil: " + hasil);
</SCRIPT>
</BODY>
</HTML>
Hasil :
Script :
<HTML>
<HEAD>
<TITLE>Contoh if-else</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE = "JavaScript">
var nilai = prompt("Nilai (0-100): ", 0);
var hasil = "";
if (nilai >= 60)
hasil = "Lulus";
else
hasil = "Tidak Lulus";
document.write("Hasil: " + hasil);
</SCRIPT>
</BODY>
</HTML>
Hasil :
0 komentar :
Posting Komentar