Advertisement
Marin171

js

Oct 22nd, 2022
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. function hairSalon(input) {
  2. let index = 0;
  3. let dailyGoal = Number(input[0]);
  4. moneyCount = 0;
  5.  
  6. command = input[index];
  7. index++;
  8.  
  9. while(moneyCount < dailyGoal) {
  10. command = Number(input[index]);
  11. index++
  12. }
  13. if (command != "closed") {
  14. type = Number(input[index]);
  15. index++;
  16. }
  17. if (command == "haircut") {
  18.  
  19. if (type == "mens") {
  20. moneyCount += 15;
  21. }
  22. if (type == "ladies") {
  23. moneyCount += 20;
  24. }
  25. if (type == "kids") {
  26. moneyCount += 10;
  27. }
  28. if (command == "color") {
  29. if (type == "touch up") {
  30. moneyCount += 20;
  31. }
  32. if (type == "full color") {
  33. moneyCount += 30;
  34. }
  35. if (command == "closed") {
  36.  
  37. }
  38. }
  39. if (moneyCount >= dailyGoal) {
  40. console.log("You have reached your target for the day!");
  41. } else {
  42. diff = abs(dailyGoal - moneyCount);
  43. console.log(`Target not reached! You need ${diff}lv. more.`);
  44. console.log(`Earned money: ${moneyCount}lv.`);
  45. }
  46. }
  47. }
  48. solve(["300",
  49. "haircut",
  50. "ladies",
  51. "haircut",
  52. "kids",
  53. "color",
  54. "touch up",
  55. "closed"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement