kStoikow

footballSouvenirs

Jun 29th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function souvenirPrice(input) {
  2.     let team = input.shift();
  3.     let souvenir = input.shift();
  4.     let quantity = Number(input.shift());
  5.     let totalSum = 0;
  6.     let price = 0;
  7.  
  8.     if (team === 'Argentina') {
  9.         if (souvenir === 'flags') {
  10.             price = 3.25 * quantity;
  11.         } else if (souvenir === 'caps') {
  12.             price = 7.2 * quantity;
  13.         } else if (souvenir === 'posters') {
  14.             price = 5.1 * quantity;
  15.         } else if (souvenir === 'stickers') {
  16.             price = 1.25 * quantity;
  17.         } else {
  18.             console.log('Invalid stock!');
  19.         }
  20.  
  21.     } else if (team === 'Brazil') {
  22.         if (souvenir === 'flags') {
  23.             price = 4.2 * quantity;
  24.         } else if (souvenir === 'caps') {
  25.             price = 8.5 * quantity;
  26.         } else if (souvenir === 'posters') {
  27.             price = 5.35 * quantity;
  28.         } else if (souvenir === 'stickers') {
  29.             price = 1.2 * quantity;
  30.         } else {
  31.             console.log('Invalid stock!');
  32.         }
  33.  
  34.     } else if (team === 'Croatia') {
  35.         if (souvenir === 'flags') {
  36.             price = 2.75 * quantity;
  37.         } else if (souvenir === 'caps') {
  38.             price = 6.9 * quantity;
  39.         } else if (souvenir === 'posters') {
  40.             price = 4.95 * quantity;
  41.         } else if (souvenir === 'stickers') {
  42.             price = 1.1 * quantity;
  43.         } else {
  44.             console.log('Invalid stock!');
  45.         }
  46.  
  47.     } else if (team === 'Denmark') {
  48.         if (souvenir === 'flags') {
  49.             price = 3.1 * quantity;
  50.         } else if (souvenir === 'caps') {
  51.             price = 6.5 * quantity;
  52.         } else if (souvenir === 'posters') {
  53.             price = 4.8 * quantity;
  54.         } else if (souvenir === 'stickers') {
  55.             price = 0.9 * quantity;
  56.         } else {
  57.             console.log('Invalid stock!');
  58.         }
  59.  
  60.     } else {
  61.         console.log('Invalid country!');
  62.     }
  63.  
  64.     if (price !== 0) {
  65.         totalSum = quantity * price;
  66.         console.log(`Pepi bought ${quantity} ${souvenir} of ${team} for ${totalSum.toFixed(2)} lv.`);
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment