Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.  
  3.     let countPeople = Number(input.shift());
  4.    
  5.  
  6.     counterBack = 0;
  7.     counterChest = 0;
  8.     counterLegs = 0;
  9.     counterAbs = 0;
  10.  
  11.     counterShake = 0;
  12.     counterBar = 0;
  13.  
  14.     counterPersonProduct = 0;
  15.     counterPersonTraining = 0;
  16.  
  17.     for (let k = 0; k < countPeople; k++) {
  18.  
  19.         let train = input.shift();
  20.         let product = input.shift();
  21.  
  22.              if (train === "Back") {
  23.                  counterBack++;
  24.                  counterPersonTraining++
  25.              } else if (train === "Chest") {
  26.                  counterChest++;
  27.                  counterPersonTraining++;
  28.              } else if (train === "Legs") {
  29.                  counterLegs++;
  30.                  counterPersonTraining++;
  31.              } else if (train === "Abs") {
  32.                  counterAbs++;
  33.                  counterPersonTraining++;
  34.              } else if (product === "Protein Shake") {
  35.                  counterShake++;
  36.                  counterPersonProduct++;
  37.              } else {
  38.                  counterBar++;
  39.                  counterPersonProduct++;
  40.              }
  41.    
  42.    
  43.    
  44.     }
  45.    
  46.  
  47.  peopleTrainig = counterChest + counterLegs + counterBack + counterAbs;
  48.   percent = (countPeople/peopleTrainig)*100;
  49.  
  50.  peopleProduct = counterShake +counterBar;
  51.  percentProduct = (countPeople/ peopleProduct)*100;
  52.  
  53.  
  54.    
  55.  
  56. console.log(`${counterBack} - back`)
  57. console.log(`${counterChest} - chest`)
  58. console.log(`${counterLegs} - legs`)
  59. console.log(`${counterAbs} - abs`)
  60. console.log(`${counterShake} - protein shake`)
  61. console.log(`${counterBar} - protein bar`)
  62. console.log(`${peopleTrainig.toFixed(2)}% - work out`)
  63. console.log(`${peopleProduct.toFixed(2)}% - protein`)
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement