Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fitnessCenter(input) {
- let visitors = Number(input.shift());
- let back = 0;
- let chest = 0;
- let legs = 0;
- let abs = 0;
- let proteinShake = 0;
- let proteinBar = 0;
- for (let i = 0; i < visitors; i++) {
- let action = input.shift();
- switch (action) {
- case "Back":
- back++;
- break;
- case "Chest":
- chest++;
- break;
- case "Legs":
- legs++;
- break;
- case "Abs":
- abs++;
- break;
- case "Protein shake":
- proteinShake++;
- break;
- case "Protein bar":
- proteinBar++;
- break;
- }
- }
- console.log(`${back} - back`);
- console.log(`${chest} - chest`);
- console.log(`${legs} - legs`);
- console.log(`${abs} - abs`);
- console.log(`${proteinShake} - protein shake`);
- console.log(`${proteinBar} - protein bar`);
- console.log(`${((back + chest + legs + abs) / visitors * 100).toFixed(2)}% - work out`);
- console.log(`${((proteinShake + proteinBar) / visitors * 100).toFixed(2)}% - protein`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement