Guessing_Game

Guessing_Game - Guessing game Write a javascript program...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Guessing game Write a javascript program that has the user enter information about a person, such as their name, age and how often they date. It compares them against a winning person (which is initialized to someone you invent). If the entered person is “better” than the current winning person, they become the winning person. This repeats three times. The program then prints out the winner. The object of the game is for the user to guess what the programmer means by one person being better than another. Your program should use an object to represent the winner, and it should store that object in the variable winner. Use another object to represent the most recently entered person. If the most recently entered person is “better” than the winner, then assign the most recently entered person/object to the variable winner. Use a for loop so that this occurs 3 times. For instance, my version has this conversation with the user (whose entries into the prompt boxes are in red): Name? Todd Age: 54 Dating: no, I’m married Name? Andrew Age: 31 Dating: no Name? Sung Young Age:35 Dating: Yes indeed The winner is Larry the Lounge Lizard! Age: 34 Dating: sporadically In this case, the default person won over all 3 people that were entered. However, if the user is lucky, they may enter a person who wins over the default person, as in this case: Name? Todd Age: 54 Dating: often Name? Andrew Age: 31 Dating: no Name? Sung Young Age:35 Dating: Yes indeed The winner is Todd! Age: 54 Dating: often The object of the game is for the user to guess what makes one person better than another. You can implement any definition of “better” that you want. Mine was X.dating==”often” where X is the variable holding the object representing the most recently entered person. ...
View Full Document

Ask a homework question - tutors are online