// Number of teams in competition
numTeam = eval(prompt("Number of Teams in Competition"));
// For loop
for (var comp = 1; comp <= numTeam; comp = comp + 1)
{
// Prompt for the team's name
team_Name = prompt("What is the Team's Name?");
// Matches played
matches = eval(prompt("Number of matches played"));
for (var game = 1; game <= matches; game = game + 1)
{
// Prompts for Goals Scored
goal1 = eval(prompt("Enter goal's scored for Team 1"));
goal2 = eval(prompt("Enter goal's scored for Team 2"));
// If-Then Else Statement to see if the team either, won, lost, or drew their game
if (goal1 > goal2)
{
winGame = winGame + 1;
} else if (goal1 < goal2)
{
loseGame = loseGame + 1;
} else if (goal1 = goal2)
{
drawGame = drawGame + 1;
} else
{
alert("There is an error")
}
// Amount of points won
win = winGame * pointsWin
// Amount of points lost
loss = loseGame * pointsLose
// Amount of points from draws.
draw = drawGame * pointsDraw
// Total amount of points from wins, losses and draw's
total = win + loss + draw
alert("Team Name: " + team_Name + "\nNumber of matches Won: " + winGame + "\nNumber of matches Lost: " + loseGame + "\nNumber of matches Drawn: "
+ drawGame+ "\nFinal team score: " + total);
}
}
Bookmarks