JSFiddle - React, Tailwind, and code Playground
by Orikrin1998
JavaScript
// Script d'origine pour les groupes : /73/
// Libertés prises : tirage au sort en cas d'égalité parfaite
function compare(a,b) {
if (a.score > b.score)
return -1;
if (a.score < b.score)
return 1;
if (a.score == b.score)
if (a.diff > b.diff)
return -1;
if (a.diff < b.diff)
return 1;
if (a.diff == b.diff)
randomWinners = [1,-1];
randomWinner = randomWinners[Math.floor(Math.random() * 2)];
return randomWinner;
}
// _____ GROUPE A _____ //
team1 = "Brésil";
team2 = "Mexique";
team3 = "Croatie";
team4 = "Cameroun";
scoreTeam1 = 0;
scoreTeam2 = 0;
scoreTeam3 = 0;
scoreTeam4 = 0;
diffTeam1 = 0;
diffTeam2 = 0;
diffTeam3 = 0;
diffTeam4 = 0;
var scoreTeam1_2 = parseInt(Math.floor(5 * Math.random() + 0));
var scoreTeam1_3 = parseInt(Math.floor(5 * Math.random() + 0));
var scoreTeam1_4 = parseInt(Math.floor(5 * Math.random() + 0));
var scoreTeam2_3 = parseInt(Math.floor(5 * Math.random() + 0));
var scoreTeam2_4 = parseInt(Math.floor(5 * Math.random() + 0));
var scoreTeam3_4 = parseInt(Math.floor(5 * Math.random() + 0));
var scoreTeam2_1 = parseInt(Math.floor(5 * Math.random() + 0));
var scoreTeam3_1 = parseInt(Math.floor(5 * Math.random() + 0));
var scoreTeam4_1 = parseInt(Math.floor(5 * Math.random() + 0));
var scoreTeam3_2 = parseInt(Math.floor(5 * Math.random() + 0));
var scoreTeam4_2 = parseInt(Math.floor(5 * Math.random() + 0));
var scoreTeam4_3 = parseInt(Math.floor(5 * Math.random() + 0));
match1 = team1 + " " + scoreTeam1_2 + " - " + scoreTeam2_1 + " " + team2;
if (scoreTeam1_2 == scoreTeam2_1) {
scoreTeam1 += 1;
scoreTeam2 += 1;
} else if (scoreTeam1_2 > scoreTeam2_1) {
scoreTeam1 += 3;
diffTeam1 += scoreTeam1_2 - scoreTeam2_1;
diffTeam2 += scoreTeam2_1 - scoreTeam1_2;
} else if (scoreTeam1_2 < scoreTeam2_1) {
scoreTeam2 += 3;
diffTeam1 += scoreTeam1_2 - scoreTeam2_1;
diffTeam2 += scoreTeam2_1 -...