TZinovieva

Painting Eggs JS

Dec 22nd, 2022
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function paintingEggs(input) {
  2.     let size = input[0];
  3.     let colour = input[1];
  4.     let batches = Number(input[2]);
  5.  
  6.     let price = 0;
  7.     switch (size) {
  8.         case "Large":
  9.             if (colour === "Red") {
  10.                 price = 16 * batches;
  11.             } else if (colour === "Green") {
  12.                 price = 12 * batches;
  13.             } else {
  14.                 price = 9 * batches;
  15.             }
  16.             break;
  17.         case "Medium":
  18.             if (colour === "Red") {
  19.                 price = 13 * batches;
  20.             } else if (colour === "Green") {
  21.                 price = 9 * batches;
  22.             } else {
  23.                 price = 7 * batches;
  24.             }
  25.             break;
  26.         case "Small":
  27.             if (colour === "Red") {
  28.                 price = 9 * batches;
  29.             } else if (colour === "Green") {
  30.                 price = 8 * batches;
  31.             } else {
  32.                 price = 5 * batches;
  33.             }
  34.         default:
  35.             break;
  36.     }
  37.     let totalCosts = price - price * 0.35;
  38.     console.log(`${totalCosts.toFixed(2)} leva.`);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment