Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function smallShop([product, town, quantity]) {
- // Transform quantity to a number and convert the string to lowercase letters.
- quantity = Number(quantity)
- town = town.toLowerCase()
- product = product.toLowerCase()
- // Checking if the town is Sofia, Plovdiv or Varna.
- // Checking also for each town whether product is coffee, water, beer, sweats or peanuts. Then calculate the quantity by price.
- if (town == 'sofia') {
- if (product == 'coffee') {
- console.log(quantity * 0.5)
- } else if (product == 'water') {
- console.log(quantity * 0.8)
- } else if (product == 'beer') {
- console.log(quantity * 1.2)
- } else if (product == 'sweets') { instead of sweats
- console.log(quantity * 1.45)
- } else if (product == 'peanuts') {
- console.log(quantity * 1.6)
- }
- } else if (town == 'plovdiv') {
- if (product == 'coffee') {
- console.log(quantity * 0.4)
- } else if (product == 'water') {
- console.log(quantity * 0.7)
- } else if (product == 'beer') {
- console.log(quantity * 1.15)
- } else if (product == 'sweets') { instead of sweats
- console.log(quantity * 1.3)
- } else if (product == 'peanuts') {
- console.log(quantity * 1.5)
- }
- } else if (town == 'varna') {
- if (product == 'coffee') {
- console.log(quantity * 0.45)
- } else if (product == 'water') {
- console.log(quantity * 0.7)
- } else if (product == 'beer') {
- console.log(quantity * 1.1)
- } else if (product == 'sweets') { instead of sweats
- console.log(quantity * 1.35)
- } else if (product == 'peanuts') {
- console.log(quantity * 1.55)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement