Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function smallShop(input){
- let productName = input.shift();
- let town = input.shift();
- let quantity = Number(input.shift());
- let totalSum =0.0;
- if (productName=="coffee"){
- if(town == "Sofia"){
- totalSum = quantity*0.5;
- }else if(town == "Plovdiv"){
- totalSum = quantity*0.4;
- }else if(town =="Varna"){
- totalSum = quantity*0.45;
- }
- }
- if (productName=="water"){
- if(town == "Sofia"){
- totalSum = quantity*0.8;
- }else if(town == "Plovdiv"){
- totalSum = quantity*0.7;
- }else if(town =="Varna"){
- totalSum = quantity*0.7;
- }
- }
- if (productName=="beer"){
- if(town == "Sofia"){
- totalSum = quantity*1.2;
- }else if(town == "Plovdiv"){
- totalSum = quantity*1.15;
- }else if(town =="Varna"){
- totalSum = quantity*1.1;
- }
- }
- if (productName=="sweets"){
- if(town == "Sofia"){
- totalSum = quantity*1.45;
- }else if(town == "Plovdiv"){
- totalSum = quantity*1.30;
- }else if(town =="Varna"){
- totalSum = quantity*1.35;
- }
- }
- if (productName=="peanuts"){
- if(town == "Sofia"){
- totalSum = quantity*1.60;
- }else if(town == "Plovdiv"){
- totalSum = quantity*1.50;
- }else if(town =="Varna"){
- totalSum = quantity*1.55;
- }
- }
- console.log(totalSum);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement