Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function bestPlayer(input) {
- let bestPlayer = "";
- let bestScore = 0;
- for(let i = 0; i < input.length && bestScore < 10; i++){
- let player = input[i++];
- let goals = Number(input[i]);
- if (goals > bestScore) {
- bestPlayer = player;
- bestScore = goals;
- }
- }
- console.log(`${bestPlayer} is the best player!`);
- if (bestScore < 3) {
- console.log(`He has scored ${bestScore} goals.`);
- } else {
- console.log(`He has scored ${bestScore} goals and made a hat-trick !!!`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement