Advertisement
Guest User

Untitled

a guest
May 19th, 2021
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function countScores(input) {
  2.     let winMatches = 0;
  3.     let lostMatches = 0;
  4.     let drawMatches = 0;
  5.  
  6.     for (i = 0; i < input.length; i++) {
  7.         let matchScore1 = input[i].substring(0, 1);
  8.         let matchScore2 = input[i].substring(2, 3);
  9.         if (matchScore1 > matchScore2) {
  10.             winMatches++;
  11.         }
  12.         else if (matchScore1 < matchScore2) {
  13.             lostMatches++;
  14.         }
  15.         else {
  16.             drawMatches++;
  17.         }
  18.     }
  19.  
  20.     console.log("Team won " + winMatches + " games.");
  21.     console.log("Team lost " + lostMatches + " games.");
  22.     console.log("Drawn games: " + drawMatches);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement