Javascript problem

Status
Not open for further replies.
*Note: I turned in my code for this already to the instructor, so I will now state what the text problem says ....

"You can determine whether a year is a leap year by testing if it is divisible by 4. However, years that are divisible by 100 are not leap years, unless they are also divisible by 400, in which case they are leap years. Write a script that allows a user to enter a year and then determines whether the year entered is a leap year. Include a form with a single text box where the user can enter a year. Display an alert dialog box to the user stating whether the year they entered is a standard year or a leap year. "

Source: Javascript 4th Edition, Thomson Course Technology

So basically, CrazeD, to answer your question, the above code (mine) was my attempt to put all this together based on the text book problem. Does this make any more sense reading that to see what I was trying to do with my Javascript code ? Your solution gave me the right answers, but it didn't check out the other two scenarios. And that is because you didn't know the rest of the problem. So does this help you to see the problem clearer ?
As I said, I turned this in already, so any answers I get won't be applied to my homework (I'm not a cheater :p).
 
That doesn't really clear it up for me. :p

Seems like extra work really. Any year that is divisible by 4 is a leap year, so I don't understand why you'd need to divide by 100 and 400 as well.
 
Actually, I don't understand it either, but that was in the book as you can see. I never sat and figured out WHY the question was written that way, they (whoever "they" are) must have found that mathematically there are times that those other two factors need to be considered I suppose. I just went with it. I want to say thanks for all your help, CrazeD ;)
 
Status
Not open for further replies.
Back
Top Bottom