fumanbest

The Best Player

Apr 6th, 2021
342
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]);
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×