Advertisement
Guest User

Untitled

a guest
May 19th, 2021
756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function countScores(input) {
  2.  
  3.     let firstMatchResult = input[0];
  4.     let secondMatchResult = input[1];
  5.     let thirdMatchResult = input[2];
  6.  
  7.     let winMatches = 0;
  8.     let lostMatches = 0;
  9.     let drawMatches = 0;
  10.  
  11.     let matchScore1 = firstMatchResult.substring(0, 1);
  12.     let matchScore2 = firstMatchResult.substring(2, 3);
  13.  
  14.  
  15.     if (matchScore1 > matchScore2) {
  16.         winMatches++;
  17.     }
  18.     else if (matchScore1 < matchScore2) {
  19.         lostMatches++;
  20.     }
  21.     else {
  22.         drawMatches++;
  23.     }
  24.  
  25.     matchScore1 = secondMatchResult.substring(0, 1);
  26.     matchScore2 = secondMatchResult.substring(2, 3);
  27.  
  28.  
  29.     if (matchScore1 > matchScore2) {
  30.         winMatches++;
  31.     }
  32.     else if (matchScore1 < matchScore2) {
  33.         lostMatches++;
  34.     }
  35.     else {
  36.         drawMatches++;
  37.     }
  38.  
  39.     matchScore1 = thirdMatchResult.substring(0, 1);
  40.     matchScore2 = thirdMatchResult.substring(2, 3);
  41.  
  42.     if (matchScore1 > matchScore2) {
  43.         winMatches++;
  44.     }
  45.     else if (matchScore1 < matchScore2) {
  46.         lostMatches++;
  47.     }
  48.     else {
  49.         drawMatches++;
  50.     }
  51.  
  52.     console.log("Team won " + winMatches + " games.");
  53.     console.log("Team lost " + lostMatches + " games.");
  54.     console.log("Drawn games: " + drawMatches);
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement