Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function PCGameShop(input) {
- let n = Number(input[0]);
- let hearthstone = 0;
- let fornite = 0;
- let overwatch = 0;
- let others = 0;
- for (let i = 0; i < n; i++) {
- let game = "";
- switch (game) {
- case "Hearthstone":
- hearthstone++;
- case "Fornite":
- fornite++;
- case "Overwatch":
- overwatch++;
- default:
- others++;
- break;
- }
- console.log(`Hearthstone - ${(hearthstone * 1.0 / n * 100).toFixed(2)}%`);
- console.log(`Fornite - ${(fornite * 1.0 / n * 100).toFixed(2)}%`);
- console.log(`Overwatch - ${(overwatch * 1.0 / n * 100).toFixed(2)}%`);
- console.log(`Others - ${(others * 1.0 / n * 100).toFixed(2)}%`);
- }
- }
- PCGameShop(["4", "Hearthstone", "Fornite", "Overwatch", "Others"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement