Advertisement
Spocoman

Hair Salon

Feb 20th, 2022
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function hairSalon (input) {
  2.     let target = Number(input.shift());
  3.     let sum = 0;
  4.  
  5.     while (target > sum) {
  6.         let service = input.shift();
  7.         if (service === "closed") {
  8.             break;
  9.         } else {
  10.             let person = input.shift();
  11.             if (service === "haircut") {
  12.                 if (person === "mens") {
  13.                     sum += 15;
  14.                 } else if (person === "ladies") {
  15.                     sum += 20;
  16.                 } else if (person === "kids") {
  17.                     sum += 10;
  18.                 }
  19.             } else if (service === "color") {
  20.                 if (person === "touch up") {
  21.                     sum += 20;
  22.                 } else if (person === "full color") {
  23.                     sum += 30;
  24.                 }
  25.             }
  26.         }
  27.     }
  28.     if (sum >= target) {
  29.         console.log("You have reached your target for the day!");
  30.     } else {
  31.         console.log(`Target not reached! You need ${target - sum}lv. more.`);
  32.     }
  33.     console.log(`Earned money: ${sum}lv.`);
  34.    
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement