Hi I am currently writing a program to analyse (to a degree), the points scored in a dance contest. The program mainly works so far. However I am struggling to conclude the program end. Using an if
statement, I would like to compute if a dance-off is required, looping through the combinedPointsArray
and determining if 2 or more numbers hold the higest score and are equal.
The aim is to provide:
- Maximum number of combined points
- The couples and their combined points
- The couples names with the highest points
- If two or more couples have equal highest combined points - output whether a dance-off is required.
This is my program so far:
<LINK REL="shortcut icon" TYPE="image/x-icon" HREF="favicon.ico">
Latin Dancing Contest
var contestantNamesArray = ['Tom and Nazia', 'Pat and Dan', 'Sandra and Kofi', 'Ian and Adele', 'Paul and Costas'];
var judgesPointsArray = [2,1,5,4,3];
var audiencePointsArray = [4,5,2,3,1];
var combinedPointsArray = new Array (judgesPointsArray.length)
combinedPointsArray[x] = parseInt( judgesPointsArray[x] + audiencePointsArray[x] );
var biggest = 0;
var values = new Array();
if (combinedPointsArray[x] >= biggest )
biggest = parseInt(combinedPointsArray[x]);
if ( values == biggest )
document.write('A Dance-off is required <BR><BR> ');
document.write('The biggest score was : ' + (biggest));
// Use a for loop to step through the two arrays and print
// the values in the table.
for (var i=0; i<contestantNamesArray.length; i++)
document.write("<tr><td>" + contestantNamesArray[i] + "</td>");
document.write("<td>" + combinedPointsArray[i] + "</td></tr>");
Any help would be really appreciated. I have spent so long on this; consequently I am pulling my hair out.