Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solution(input) {
- let product = (input.shift());
- let city = (input.shift());
- let quantity = Number(input.shift());
- let totalSum = 0;
- if (product === 'coffee') {
- if (city === 'Sofia') {
- totalSum = quantity * 0.50;
- } else if (city === 'Plovdiv') {
- totalSum = quantity * 0.40;
- } else {
- totalSum = quantity * 0.45;
- }
- } else if (product === 'water') {
- if (city === 'Sofia') {
- totalSum = quantity * 0.80;
- } else if (city === 'Plovdiv') {
- totalSum = quantity * 0.70;
- } else {
- totalSum = quantity * 0.70;
- }
- } else if (product === 'beer') {
- if (city === 'Sofia') {
- totalSum = quantity * 1.20;
- } else if (city === 'Plovdiv') {
- totalSum = quantity * 1.15;
- } else {
- totalSum = quantity * 1.10;
- }
- } else if (product === 'sweets') {
- if (city === 'Sofia') {
- totalSum = quantity * 1.45;
- } else if (city === 'Plovdiv') {
- totalSum = quantity * 1.30;
- } else {
- totalSum = quantity * 1.35;
- }
- if (city === 'Sofia') {
- totalSum = quantity * 1.60;
- } else if (city === 'Plovdiv') {
- totalSum = quantity * 1.50;
- } else {
- totalSum = quantity * 1.55;
- }
- } else {
- }
- console.log(totalSum);
- }
- solution([
- 'water',
- 'Plovdiv',
- '3'
- ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement