SHARE
TWEET

Untitled

a guest Feb 27th, 2020 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve (input) {
  2.  
  3.     let games = Number(input.shift());
  4.  
  5.     let counterHearthstore = 0;
  6.     let counterFornite = 0;
  7.     let counterOverwatch = 0;
  8.     let counterOthers = 0;
  9.  
  10.     for (let i = 0; i <= games;i++) {
  11.         let nameGame = input.shift();
  12.          
  13.         switch (nameGame) {
  14.             case "Hearthstone":
  15.             counterHearthstore++;
  16.             break;
  17.  
  18.             case "Fornite":
  19.             counterFornite++;
  20.             break;
  21.  
  22.             case "Overwatch":
  23.             counterOverwatch++;
  24.             break;
  25.  
  26.             case "Others":
  27.             counterOthers++;
  28.             break;
  29.  
  30.         }
  31.      
  32.     }
  33.      
  34. console.log(`Hearthstone - ${(counterHearthstore/games * 100).toFixed(2)}%`);
  35. console.log(`Fornite - ${(counterFornite/games * 100).toFixed(2)}%`);
  36. console.log(`Overwatch - ${(counterOverwatch/games * 100).toFixed(2)}%`);
  37. console.log(`Others - ${(counterOthers/games * 100).toFixed(2)}%`);
  38.  
  39. }
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