SHARE
TWEET

PCGameShop

a guest Feb 27th, 2020 110 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let games = Number(input.shift());
  3.     let counterHearthstore = 0;
  4.     let counterFornite = 0;
  5.     let counterOverwatch = 0;
  6.     let counterOthers = 0;
  7.     for (let i = 0; i < games; i++) {
  8.         let nameGame = input.shift();
  9.         switch (nameGame) {
  10.             case 'Hearthstone':
  11.                 counterHearthstore++;
  12.                 break;
  13.             case 'Fornite':
  14.                 counterFornite++;
  15.                 break;
  16.             case 'Overwatch':
  17.                 counterOverwatch++;
  18.                 break;
  19.             default:
  20.                 counterOthers++;
  21.                 break;
  22.         }
  23.     }
  24.     console.log(`Hearthstone - ${((counterHearthstore / games) * 100).toFixed(2)}%`);
  25.     console.log(`Fornite - ${((counterFornite / games) * 100).toFixed(2)}%`);
  26.     console.log(`Overwatch - ${((counterOverwatch / games) * 100).toFixed(2)}%`);
  27.     console.log(`Others - ${((counterOthers / games) * 100).toFixed(2)}%`);
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top