Guest User

Untitled

a guest
May 28th, 2020
47
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function dishwasher(input) {
  2.     let littersDetergent = Number(input.shift());
  3.     let detergent = littersDetergent * 750;
  4.  
  5.     let numberOfConteiners = "";
  6.     let conteiners = 0;
  7.     let counter = 0;
  8.     let disheWashed = 0;
  9.     let potsWashed = 0;
  10.  
  11.     while (true) {
  12.         numberOfConteiners = input.shift();
  13.         if (numberOfConteiners == "End") {
  14.             break;
  15.         }
  16.         counter++;
  17.         if (counter % 3 == 0){
  18.             conteiners = Number(numberOfConteiners);
  19.             potsWashed += conteiners;
  20.             detergent -= conteiners * 0.15;
  21.         }else{
  22.             conteiners = Number(numberOfConteiners);
  23.             disheWashed += conteiners;
  24.             detergent -= conteiners * 0.5;
  25.         }
  26.         if (detergent < 0){
  27.             console.log(`Not enough detergent, ${math.abs(detergen)} ml. more necessary!`)
  28.             return;
  29.         }
  30.     }
  31.     console.log("Detergent was enough!");
  32.             console.log(`${disheWashed} dishes and ${potsWashed} pots were washed.`);
  33.             console.log(`Leftover detergent ${Math.abs(detergent)} ml.`)
  34.  
  35. }
RAW Paste Data