-
Notifications
You must be signed in to change notification settings - Fork 1
/
latihan4js.html
39 lines (34 loc) · 952 Bytes
/
latihan4js.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<script>
//variable
let pelanggan = "Siti ";
let produk = "TV";
//tv => 3 jt, kulkas => 4 jt, AC => 5 juta
// if(produk == "TV"){
// harsat = 3000000;
// }
// else if (produk == "Kulkas"){
// harsat = 4000000;
// } else if (produk == "AC"){
// harsat = 5000000;
// }
// else {
// harsat = 0;
// }
let harsat = 0;
switch(produk){
case 'TV': harsat = 3000000; break;
case 'Kulkas': harsat = 4000000; break;
case 'AC': harsat = 5000000; break;
default: harsat = 0;
}
let jmlBeli = 15;
let bruto = harsat * jmlBeli;
//ternary
let diskon =(produk == 'AC') ? 0.1 * bruto : 0;
document.write("Data Pembelian"+
"<br> Pelanggan : " + pelanggan +
"<br> Produk Pilihan : " + produk +
"<br> Harga Satuan : " + harsat +
"<br> Harga Kotor (bruto) : "+ bruto +
"<br> Diskon : " + diskon);
</script>