Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

110
Views
code a function if we had equal points between two teams in quiz app

i make quiz app It displays the winner now if the number of questions expires and counts the points, but I want it in the event of the points being equal to display a message that the points is equal and then go back to answer a new question I had a hard time solving this, can you help me?

  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;
  }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!