Freight Language Demo Page
To see what this page is about,
view the article
.
Input
Set pricePerKG to 2.5; If region is "asia" [ set pricePerKG to 2.2; ] Set totalWeight to 0; loop through order [ Set totalWeight to totalWeight + (quantity * weight); ] Set freightCost to totalWeight * pricePerKG; if customer is "VIP" [ set freightCost to freightCost * 0.7; ] Freight cost is freightCost;
Converted to JavaScript:
Sample input
Customer type:
VIP
Normal
Delivery region:
Africa
Asia
Americas
Europe
Middle East
Products ordered:
Quantity
Product Name
Weight
External drive
1.2
Keyboard
0.2
Computer
10.4
Monitor
5.3