Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function basketballTournament(input) {
- let tournament, games, team1, team2, win = 0, lost = 0;
- while ((tournament = input.shift()) !== "End of tournaments") {
- games = Number(input.shift());
- for (let game = 1; game <= games; game++) {
- team1 = Number(input.shift());
- team2 = Number(input.shift());
- if (team1 > team2) {
- console.log(`Game ${game} of tournament ${tournament}: win with ${team1 - team2} points.`);
- win++;
- } else {
- console.log(`Game ${game} of tournament ${tournament}: lost with ${team2 - team1} points.`);
- lost++;
- }
- }
- }
- console.log(`${(win / (win + lost) * 100).toFixed(2)}% matches win`);
- console.log(`${(lost / (win + lost) * 100).toFixed(2)}% matches lost`);
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement