code a function if we hadequal points in quiz app

28 Views Asked by At

i make quiz app It displays the winner now if the number of questions expires and counts the points, but I want itin the event of the points being equal to display a message

  self.showWinner = function () {
  // who has the most points?
  let team_data = {};
  for (let team_name of self.teams)
    team_data[team_name] = 0;
  for (let action of self.actions) {
    
    if (self.rounds[self.current.round].indexOf(action.category) === -1)
      continue;
     
    if (action.correct)
      team_data[action.team] += action.difficulty;
    else
      team_data[action.team] -= action.difficulty;
  }
  let name;
  let points = -99999;
  for (let team_name in team_data) {
    if (team_data[team_name] > points) {
      points = team_data[team_name];
      name = team_name;
    }
  }

  // show screen
  $("#overlay").show();
  $("#overlay > *").hide();
  $("#overlay #winner").show();
  $("#winner .text").text(name + " (" + points + " pt)");

  // reset game
  self.teams = [];
};
 if (self.current.round !== undefined && answered_questions === 4) {
    setTimeout(self.showWinner, 10);
    return;
  }
0

There are 0 best solutions below