Skip to content

Instantly share code, notes, and snippets.

@bluejack
Last active November 12, 2018 17:37
Show Gist options
  • Save bluejack/550300e5ca73188ba1c715cd9e43b9f2 to your computer and use it in GitHub Desktop.
Save bluejack/550300e5ca73188ba1c715cd9e43b9f2 to your computer and use it in GitHub Desktop.
Javascript array of arrays for Ian Brown
var ballots[]
onEvent("submitBtn", "click", function(){
var newBallot = [getNumber("rank1"), getNumber("rank2"), getNumber("rank3"), getNumber("rank4"), getNumber("rank5")]
ballots.push(newBallot)
console.log (newBallot)
console.log ("We now have " + ballots.length + " in our system!"
});
// Here's a little sample to show how you might begin to tabulate the ballots...
function tabulateBallots() {
var len = ballots.length
var rankOneTotal 0;
for (var i = 0; i < len; i++) {
var b = ballots[i]
console.log(b)
rankOneTotal += b[0]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment