IT-202: Assignment #5, Spring Quarter 2025

Friendly Reminder

I will probably also be sending this out via News posting as well.

I do not feel that this reminder is necessary for your section as you folks have been doing a really terrific job. Your focus in the classroom has been -- and I don't use this term lightly -- outstanding. While there have been a couple of people doing so, it has been very rare for me to see people checking phones, doing unrelated things on laptops etc during lecture.

But I do want to send out a friendly reminder that these assignments are for YOU to learn, and to establish for yourself how well you understand the material. In other words, while it is certainly possible to cheat via all the usual methods (using AI, have a friend "help", Chegg, etc, etc) remember that in this course, the assignments are only worth a relatively small percentage of your grade. The major determining factor of your grade is the exams.

The purpose of these assignments is to really push you to go back and ensure you understand and consolidate the course material. DOING PROBLEMS is how we learn to code! Plus, it is what will enable you to do very well on the tests!

Again, this is just a reminder. It has not been a big problem in this course. Keep up the great effort!

Overview

You are going to create a simple page that determines whether or not the current day is the user's birthday. To do this, you will need to use conditionals, at least one logical operator, and the Date() object. All of this was demonstrated and practiced with in lecture.

Your page should look like the following although the styling (e.g. borders, etc) may be somewhat different:

Items

Calculation:

Determining whether or not it is the user's birthday will involve the following:

  1. Determine the current day of the month (e.g. 22nd, 18th, 30th, etc) by using the Date() object as shown in lecture. I also provide some partial reminders on this below. Store this value in a variable.

  2. Determine the month by using the Date() object. Store this value in a variable. Again, I have some reminders on this below.

  3. From the form, determine the user's birth day and birth month, and store both of those in variables.

Results

Output (to a div section) whether or not it is the user's birthday.

Here is an example that I tested on May 22nd. Note that I specify the user's birthdate as January 22nd. In other words, it is NOT the user's birthday:

 

Here is an example that I tested on May 22nd. Note that I specify the user's birthdate as May 22nd. In other words, it IS the user's birthday:

Styling

In an external stylesheet, do the following:

Tips & Reminders

 

Code for the month select box

As mentioned above, here is the code to create the select box. To save you some typing, I've done it for you. Copy this code into your own assignment.

 

Research

As a JavaScript comment, briefly explain why it is preferable to use a select box for the user to enter their birth month than, say, a text field. Again, this can be brief. You don't have to spend a lot of time on it.

 

Checking for NaN

Remember: Start small and build. For example, don't worry about including this functionality until all the other stuff is working properly!

In our lecture on built in functions, we discussed how to check for NaN. When you try to parse the value for the user's day of the month, if they did not enter a valid numeric value, an NaN error will be generated. Using an if block (a separate block -- not the same one you used previously), check for this error. If the user entered a non numeric value, output: You must enter a valid day. Output this message to the div section.

This message should be in a contrasting color (e.g. red).

New Code: To make this work, the final line of your if block where you do this error checking should be the statement return; (That's the entire line). In other words, your if block will look like this:

 

A return statement immediately terminates the function. The reason you want to terminate the function, is that you do NOT want the function to continue along it's merry way generating various errors when there is something already broken in the user's input.

 

Submission Requirements