Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function footballResults(input) {
- let wonMatches = 0;
- let lostMatches = 0
- let drawnMatches = 0;
- let hostResult = 0;
- let guestResult = 0;
- for (let i = 0; i <= 2; i++) {
- let match = input[i];
- hostResult = match.charAt(0);
- guestResult = match.charAt(2);
- if (hostResult > guestResult) {
- wonMatches++;
- } else if (hostResult < guestResult) {
- lostMatches++;
- } else if (hostResult === guestResult) {
- drawnMatches++;
- }
- }
- console.log(`Team won ${wonMatches} games.`);
- console.log(`Team lost ${lostMatches} games.`);
- console.log(`Drawn games: ${drawnMatches}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment