Mode:
Duration:
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
cart = {}
total = 0
updateUI = ->
print "Cart Items:"
for item, price in pairs cart
print "#{item}: $#{price}"
print "Total: $#{total}"
print '----------------'
addItem = (item, price) ->
cart[item] = price
total += price
updateUI!
removeItem = (item) ->
if cart[item]
total -= cart[item]
cart[item] = nil
updateUI!
# Simulate actions
addItem 'Apple', 2
addItem 'Banana', 3
removeItem 'Apple'Coding works best on desktop or with an external keyboard.