Advertisement
Liliana797979

PC Game shop

Feb 3rd, 2021
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function PCGameShop(input) {
  2.     let n = Number(input[0]);
  3.     let hearthstone = 0;
  4.     let fornite = 0;
  5.     let overwatch = 0;
  6.     let others = 0;
  7.  
  8.     for (let i = 0; i < n; i++) {
  9.         let game = "";
  10.         switch (game) {
  11.             case "Hearthstone":
  12.                 hearthstone++;
  13.             case "Fornite":
  14.                 fornite++;
  15.             case "Overwatch":
  16.                 overwatch++;
  17.                 default:
  18.                 others++;
  19.                 break;
  20.         }
  21.         console.log(`Hearthstone - ${(hearthstone * 1.0 / n * 100).toFixed(2)}%`);
  22.         console.log(`Fornite - ${(fornite * 1.0 / n * 100).toFixed(2)}%`);
  23.         console.log(`Overwatch - ${(overwatch * 1.0 / n * 100).toFixed(2)}%`);
  24.         console.log(`Others - ${(others * 1.0 / n * 100).toFixed(2)}%`);
  25.     }
  26. }
  27.  
  28. PCGameShop(["4", "Hearthstone", "Fornite", "Overwatch", "Others"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement