Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function trekkingMania(input) {
- let groupsQty = Number(input[0]);
- let groupMusala = 0;
- let groupMontblank = 0;
- let groupKilimanjaro = 0;
- let groupK2 = 0;
- let groupEverest = 0;
- let totalPeople = 0;
- for (let i = 1; i < input.length; i++) {
- let group = Number(input[i]);
- totalPeople += group;
- if (group <= 5) {
- groupMusala += group;
- } else if (group <= 12) {
- groupMontblank += group;
- } else if (group <= 25) {
- groupKilimanjaro += group;
- } else if (group >= 26 && group <= 40) {
- groupK2 += group;
- } else {
- groupEverest += group;
- }
- }
- let percentMusala = (groupMusala / totalPeople) * 100;
- let percentMontblanc = (groupMontblank / totalPeople) * 100;
- let percentKilimanjaro = (groupKilimanjaro / totalPeople) * 100;
- let percentK2 = (groupK2 / totalPeople) * 100;
- let percentEverest = (groupEverest / totalPeople) * 100;
- console.log(percentMusala.toFixed(2) + "%");
- console.log(percentMontblanc.toFixed(2) + "%");
- console.log(percentKilimanjaro.toFixed(2) + "%");
- console.log(percentK2.toFixed(2) + "%");
- console.log(percentEverest.toFixed(2) + "%");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement