Advertisement
fumanbest

The Best Player

Apr 6th, 2021
501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function bestPlayer(input){
  2.     let i=0;
  3.     let max=0;
  4.     let best;
  5.     while(input[i]!="END"){
  6.         let name=input[i];
  7.         let br=Number(input[i+1]);
  8.         if(br>max) {max=br;
  9.             best=name;}
  10.         if(max>=10) break;
  11.         i+=2;
  12.     }
  13.     console.log(`${best} is the best player!`);
  14.     if(max>=3) console.log(`He has scored ${max} goals and made a hat-trick !!!`);
  15.     else console.log(`He has scored ${max} goals.`);
  16. }
  17. bestPlayer([Neymar,
  18.     2,
  19.     Ronaldo,
  20.     1,
  21.     Messi,
  22.     3,
  23.     END]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement