Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function hairSalon (input) {
- let target = Number(input.shift());
- let sum = 0;
- while (target > sum) {
- let service = input.shift();
- if (service === "closed") {
- break;
- } else {
- let person = input.shift();
- if (service === "haircut") {
- if (person === "mens") {
- sum += 15;
- } else if (person === "ladies") {
- sum += 20;
- } else if (person === "kids") {
- sum += 10;
- }
- } else if (service === "color") {
- if (person === "touch up") {
- sum += 20;
- } else if (person === "full color") {
- sum += 30;
- }
- }
- }
- }
- if (sum >= target) {
- console.log("You have reached your target for the day!");
- } else {
- console.log(`Target not reached! You need ${target - sum}lv. more.`);
- }
- console.log(`Earned money: ${sum}lv.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement