Advertisement
knoteva

Untitled

Nov 8th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function smallShop([product, town, quantity]) {
  2.    
  3.     // Transform quantity to a number and convert the string to lowercase letters.
  4.     quantity = Number(quantity)
  5.     town = town.toLowerCase()
  6.     product = product.toLowerCase()
  7.  
  8.     // Checking if the town is Sofia, Plovdiv or Varna.
  9.     // Checking also for each town whether product is coffee, water, beer, sweats or peanuts. Then calculate the quantity by price.
  10.     if (town == 'sofia') {
  11.         if (product == 'coffee') {
  12.             console.log(quantity * 0.5)
  13.         } else if (product == 'water') {
  14.             console.log(quantity * 0.8)
  15.         } else if (product == 'beer') {
  16.             console.log(quantity * 1.2)
  17.         } else if (product == 'sweets') { instead of sweats
  18.             console.log(quantity * 1.45)
  19.         } else if (product == 'peanuts') {
  20.             console.log(quantity * 1.6)
  21.         }
  22.  
  23.     } else if (town == 'plovdiv') {
  24.         if (product == 'coffee') {
  25.             console.log(quantity * 0.4)
  26.         } else if (product == 'water') {
  27.             console.log(quantity * 0.7)
  28.         } else if (product == 'beer') {
  29.             console.log(quantity * 1.15)
  30.         } else if (product == 'sweets') { instead of sweats
  31.             console.log(quantity * 1.3)
  32.         } else if (product == 'peanuts') {
  33.             console.log(quantity * 1.5)
  34.         }
  35.  
  36.     } else if (town == 'varna') {
  37.         if (product == 'coffee') {
  38.             console.log(quantity * 0.45)
  39.         } else if (product == 'water') {
  40.             console.log(quantity * 0.7)
  41.         } else if (product == 'beer') {
  42.             console.log(quantity * 1.1)
  43.         } else if (product == 'sweets') { instead of sweats
  44.             console.log(quantity * 1.35)
  45.         } else if (product == 'peanuts') {
  46.             console.log(quantity * 1.55)
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement