Advertisement
EntropyStarRover

Souvenirs

Feb 25th, 2019
158
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function souvenirs(input){
  2.     let team=input.shift();
  3.     let item=input.shift();
  4.     let quantity=input.shift();
  5.     let invalid=" ";
  6.     let price=0;
  7.  
  8.     switch(team){
  9.         case "Argentina":
  10.         switch(item){
  11.             case "flags": price=3.25; break;
  12.             case "caps": price=7.20; break;
  13.             case "posters": price=5.10; break;
  14.             case "stickers": price=1.25; break;
  15.             default: console.log("Invalid stock!"); return;
  16.         }
  17.        
  18.         break;
  19.  
  20.         case "Brazil":
  21.         switch(item){
  22.             case "flags": price=4.20; break;
  23.             case "caps": price=8.50; break;
  24.             case "posters": price=5.35; break;
  25.             case "stickers": price=1.20; break;
  26.             default: console.log("Invalid stock!"); return;
  27.         } break;
  28.         case "Croatia":
  29.         switch(item){
  30.             case "flags": price=2.75; break;
  31.             case "caps": price=6.90; break;
  32.             case "posters": price=4.95; break;
  33.             case "stickers": price=1.10; break;
  34.             default: console.log("Invalid stock!"); return;
  35.         }break;
  36.  
  37.         case "Denmark":
  38.         switch(item){
  39.             case "flags": price=3.10; break;
  40.             case "caps": price=6.50; break;
  41.             case "posters": price=4.80; break;
  42.             case "stickers": price=0.90; break;
  43.             default: console.log("Invalid stock!"); return;
  44.         } break;
  45.      
  46.         default: console.log("Invalid country!"); return;
  47.     }
  48.  
  49.     console.log(`Pepi bought ${quantity} ${item} of ${team} for ${quantity*price} lv.`);
  50.  
  51. }
Advertisement
RAW Paste Data Copied
Advertisement