Advertisement
Spocoman

Fitness Center

Feb 22nd, 2022
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function fitnessCenter(input) {
  2.     let visitors = Number(input.shift());
  3.     let back = 0;
  4.     let chest = 0;
  5.     let legs = 0;
  6.     let abs = 0;
  7.     let proteinShake = 0;
  8.     let proteinBar = 0;
  9.  
  10.     for (let i = 0; i < visitors; i++) {
  11.         let action = input.shift();
  12.  
  13.         switch (action) {
  14.             case "Back":
  15.                 back++;
  16.                 break;
  17.             case "Chest":
  18.                 chest++;
  19.                 break;
  20.             case "Legs":
  21.                 legs++;
  22.                 break;
  23.             case "Abs":
  24.                 abs++;
  25.                 break;
  26.             case "Protein shake":
  27.                 proteinShake++;
  28.                 break;
  29.             case "Protein bar":
  30.                 proteinBar++;
  31.                 break;
  32.         }
  33.     }
  34.  
  35.     console.log(`${back} - back`);
  36.     console.log(`${chest} - chest`);
  37.     console.log(`${legs} - legs`);
  38.     console.log(`${abs} - abs`);
  39.     console.log(`${proteinShake} - protein shake`);
  40.     console.log(`${proteinBar} - protein bar`);
  41.     console.log(`${((back + chest + legs + abs) / visitors * 100).toFixed(2)}% - work out`);
  42.     console.log(`${((proteinShake + proteinBar) / visitors * 100).toFixed(2)}% - protein`);
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement