Guest User

Untitled

a guest
Feb 27th, 2020
95
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2. let honorar = Number(input.shift());
  3. let command = input.shift();
  4. i = 1;
  5. let sum = 0;
  6. let guestsCounter = 0;
  7. let isTrue = true;
  8.  
  9. while (command !== "The restaurant is full") {
  10. let group = Number(command);
  11. guestsCounter += group;
  12.  
  13. if (group < 5) {
  14. sum += group * 100;
  15. } else {
  16. sum += group * 70;
  17. }
  18. if (sum >= honorar) {
  19. isTrue = false;
  20. } else {
  21. isTrue = true;
  22. }
  23.  
  24. command = input.shift();
  25. }
  26. if(command == "The restaurant is full" ){
  27. //console.log("The restaurant is full");
  28.  
  29. }
  30. if (isTrue == false) {
  31. console.log(`You have ${guestsCounter} guests and ${sum - honorar} leva left.`);
  32.  
  33. }
  34. if (isTrue == true) {
  35. console.log(`You have ${guestsCounter} guests and ${sum} leva income, but no singer.`);
  36. }
  37. }
  38. solve([
  39. "1800",
  40. "4",
  41. "4",
  42. "4",
  43. "4",
  44. "6",
  45. "6",
  46. "The restaurant is full"
  47.  
  48. ])
RAW Paste Data