-
Notifications
You must be signed in to change notification settings - Fork 0
/
satu.js
43 lines (36 loc) · 1.23 KB
/
satu.js
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
40
41
42
43
function countItem(item, qty) {
let price
let discount
let totalPrice
switch (item) {
case 'A':
price = 4550
if (qty > 13) discount = qty * 231
totalPrice = price * qty - discount
price *= qty
console.log(`- Total harga barang: ${price}`)
console.log(`- Potongan: ${discount}`)
console.log(`- Total yang harus dibayar: ${totalPrice}`)
break
case 'B':
price = 5330
if (qty > 7) discount = price * (23/100)
totalPrice = price * qty - discount
price *= qty
console.log(`- Total harga barang: ${price}`)
console.log(`- Potongan: ${discount}`)
console.log(`- Total yang harus dibayar: ${totalPrice}`)
break
case 'C':
price = 8653
totalPrice = price * qty
price *= qty
console.log(`- Total harga barang: ${price}`)
console.log(`- Potongan: Tidak ada potongan untuk barang ini`)
console.log(`- Total yang harus dibayar: ${totalPrice}`)
break
default:
`Maaf kita tidak mempunyai barang tersebut`;
}
}
countItem('A', 14)