Didalam video ini kita akan menyederhanakan penggunaan If Else pada kasus pemeriksaan data dengan jumlah yang banyak.
<!DOCTYPE html><html>
<head><title>Menyederhanakan If Else - Case Owner: @ganz</title></head>
<body>
<h1>Menyederhanakan If Else - Case Owner: @ganz</h1>
<input type=checkbox id=casing value=CASING><label for=casing>CASING</label><br />
<input type=checkbox id=cpu value=CPU><label for=cpu>CPU</label><br />
<input type=checkbox id=ram value=RAM><label for=ram>RAM</label><br />
<input type=checkbox id=monitor value=MONITOR><label for=monitor>MONITOR</label><br />
<input type=button value=CHECK onclick=checkchecked()><br /><br />
<span id=hasil></span>
<script>
function checkchecked(){
var r=["casing","cpu","ram","monitor"];
var hasil=[];
for(var i=0;i<r.length;i++){
if(document.getElementById(r[i]).checked === true){
hasil.push(document.getElementById(r[i]).value);
}
}
document.getElementById("hasil").innerText=hasil.join(",");
}
</script>
</body>
</html>
My video is at DLive