Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // problem #5
- function solve(input) {
- let sum = 0;
- let target = Number(input[0]);
- for (let i = 1; i < input.length; i += 2) {
- if (input[i] !== 'closed') {
- switch (input[i + 1]) {
- case 'mens':
- sum += 15;
- break;
- case 'ladies':
- sum += 20;
- break;
- case 'kids':
- sum += 10;
- break;
- case 'touch up':
- sum += 20;
- break;
- case 'full color':
- sum += 30;
- break;
- }
- }
- if (target <= sum) {
- console.log(`You have reached your target for the day!`);
- break;
- }
- }
- if (target > sum) {
- console.log(`Target not reached! You need ${target-sum}lv. more.`);
- }
- console.log(`Earned money: ${sum}lv.`);
- }
Add Comment
Please, Sign In to add comment