Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let countPeople = Number(input.shift());
- counterBack = 0; // let ?
- counterChest = 0;
- counterLegs = 0;
- counterAbs = 0;
- counterShake = 0;
- counterBar = 0;
- counterPersonProduct = 0; // не ти трябва
- counterPersonTraining = 0; // не ти трябва
- for (let k = 0; k < countPeople; k++) {
- let train = input.shift();
- let product = input.shift(); // ?!
- if (train === "Back") {
- counterBack++;
- counterPersonTraining++ // не ти трябва
- } else if (train === "Chest") {
- counterChest++;
- counterPersonTraining++; // ...
- } else if (train === "Legs") {
- counterLegs++;
- counterPersonTraining++; // ...
- } else if (train === "Abs") {
- counterAbs++;
- counterPersonTraining++; // ...
- } else if (product === "Protein Shake") { // shake с малко S, тия неща ги копи-пействай
- counterShake++;
- counterPersonProduct++; // ...
- } else {
- counterBar++;
- counterPersonProduct++; // ...
- }
- }
- peopleTrainig = counterChest + counterLegs + counterBack + counterAbs;
- percent = (countPeople/peopleTrainig)*100;
- peopleProduct = counterShake +counterBar;
- percentProduct = (countPeople/ peopleProduct)*100;
- console.log(`${counterBack} - back`)
- console.log(`${counterChest} - chest`)
- console.log(`${counterLegs} - legs`)
- console.log(`${counterAbs} - abs`)
- console.log(`${counterShake} - protein shake`)
- console.log(`${counterBar} - protein bar`)
- console.log(`${peopleTrainig.toFixed(2)}% - work out`) // така написано ти тук трябва да сложиш percent, a ne peopleTrainig
- console.log(`${peopleProduct.toFixed(2)}% - protein`) // percentProduct
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement