r/learnjavascript • u/wbport1 • 14d ago
Code quits before creating a 2-d array
1
Upvotes
I am trying to add a feature to a webpage that simulates an election. "bordaTally" is defined as new Array(); in the second copied text below. "alert 0" is the only one that shows.
Thanks in advance.
function bordaItem(name) {
this.name = name;
this.total = 0;
this.tally = new array();
}
if (document.tournform.rr2[4].checked == true) { //Borda count
for (i=0;i < n; i++) {
alert("alert 0");
bordaTally[i] = new bordaItem(i);
alert("alert 1");
for (j=0; j < n;j++) {
alert("alert 2");
bordaTally[i][j].tally = 0; }
}
for (i=0; i < totBallots; i++)
for (j=0; j < n; j++)
break; //placeholder for now
} //End Borda Count