Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function shop(input) {
- let product = input.shift();
- let town = input.shift();
- let quantity = Number(input.shift());
- if (product === "coffee") {
- if (town === "Sofia") {
- console.log(quantity * 0.5);
- } else if (town === "Plovdiv") {
- console.log(quantity * 0.4);
- } else {
- console.log(quantity * 0.45);
- }
- } else if (product === "water") {
- if (town === "Sofia") {
- //totalSum = quantity * 0.8; // greshno
- console.log(quantity * 0.8);
- } /*else if (town === "Plovdiv") {
- console.log(quantity * 0.7);
- }*/ else { // plovdiv i varna ednakva cena
- console.log(quantity * 0.7);
- }
- } else if (product === "beer") {
- if (town === "Sofia") {
- console.log(quantity * 1.2);
- } else if (town === "Plovdiv") {
- console.log(quantity * 1.15);
- } else {
- console.log(quantity * 1.1);
- }
- } else if (product === "sweets") {
- if (town === "Sofia") {
- console.log(quantity * 1.45);
- } else if (town === "Plovdiv") {
- console.log(quantity * 1.3);
- } else {
- console.log(quantity * 1.35);
- }
- /*if (town === "Sofia") {
- console.log(quantity * 1.6);
- } else if (town === "Plovdiv") {
- console.log(quantity * 1.5);
- } else {
- console.log(quantity * 1.55);
- }*/
- } else { // peanuts (dobaveno)
- if (town === "Sofia") {
- console.log(quantity * 1.6);
- } else if (town === "Plovdiv") {
- console.log(quantity * 1.5);
- } else {
- console.log(quantity * 1.55);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement