Advertisement
EntropyStarRover

Untitled

Mar 2nd, 2019
142
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function machinfo(input){
  2.     let team=input.shift();
  3.     let maches= Number(input.shift());
  4.     let longerGames=0;
  5.     let penaltyGames=0;
  6.     let totalTime=0;
  7.  
  8.     for (let i=1; i<=maches; i++){
  9.         let duration=Number(input.shift());
  10.         if (duration>90&& duration<=120){
  11.             longerGames++;
  12.            
  13.            
  14.         }
  15.  
  16.         if(duration>120){
  17.             penaltyGames++;
  18.         }
  19.         totalTime+=duration;
  20.     }
  21.     let average=(totalTime/maches).toFixed(2);
  22.     console.log(`${team} has played ${totalTime} minutes. Average minutes per game: ${average}`);
  23.     console.log(`Games with penalties: ${penaltyGames}`);
  24.     console.log(`Games with additional time: ${longerGames}`);
  25.  
  26. }
Advertisement
RAW Paste Data Copied
Advertisement