I am new to javascript, but I have three variables, and I want to determine which one is the largest, is there a way to put the variables into an array, or some easier way to determine which is largest?
The goal is to have the clients ask a number of questions, and with each question it increments the corresponding variable. You will notice on the link below if you test it. Once it determines which variable is largest, it will then do a document write to a span id.
I have searched, but have not found much on this.
http://www.sprayfoamsys.com/cmsdev/index.php?page=rig-constructor
After looking at the link you’ve provided, it looks like the
Math.maxsolution provided by others isn’t actually what you want, since you don’t want to know the value of the largest variable, but rather which variable is the largest. The most straightforward (and most readable) way of doing this is:Note that it is entirely possible for the user to end up with a tie, given the quiz format you’ve provided.