Score Keeper

Assignment #3

JavaScript

// Object below keeps track of games won in 1 vs 1 basketball games between my friends and I. The winner stays on allowing for multiple games to be won in a row. First person to five wins is the champion.The  two players for the first game were selected randomly from a hat.

var totalScore = {};

totalScore["Justin"] = 0;
totalScore["Jacob"] = 0;
totalScore["Steve"] = 0;
totalScore["Travis"] = 0;
totalScore["Marcus"] = 0;

totalScore["Justin"] += 1;
totalScore["Justin"] += 1;
totalScore["Jacob"] += 1;
totalScore["Jacob"] += 1;
totalScore["Jacob"] += 1;
totalScore["Steve"] +=1;
totalScore["Travis"] += 1;
totalScore["Marcus"] += 1;
totalScore["Marcus"] += 1;
totalScore["Marcus"] += 1;
totalScore["Jacob"] += 1;
totalScore["Jacob"] += 1;

// To find the contents of the object as a whole, you would write the code as follows.
alert("The winner is Jacob with " + totalScore["Jacob"] +  " wins!");