...

View Full Version : Help with a JS assignment



Vonice
12-01-2012, 12:14 AM
Hey all, I'm really new to JavaScript, and I was assigned a project I'm having a lot of trouble with. Can anyone help me out?

Here's the instructions:
Open a text editor like Notepad (Windows) or TextEdit (Mac). Create a simple web page that contains each of the following items:

-All of the tags necessary to create a basic web page
-Your name in the TITLE and BODY of the page
-two LISTs (one ordered, one non-ordered) of:
1. an assignment summary and
2. your challenges in completing the assignment
-JavaScript that performs an age calculation. The script should
-Prompt the user for a date of birth (at least year and month)
-Display the month and year entered by the user
-Display the current date (use the Date() object)
-Calculates and displays the (approximate?) age difference in Years, months
-Prints out "Happy Birthday" and counts each line for each year of age (use a loop!)

here's a link to an example picture: http://csdev.clackamas.edu/rcarino/cs150/05b-javascript2.png

Any help would be appreciated. Thanks!

VIPStephan
12-01-2012, 12:48 AM
Let me cordially point you to rule # 1.5 of the forum rules (http://www.codingforums.com/rules.htm).

That said, what have you tried so far?

Vonice
12-01-2012, 12:54 AM
Hey, I'm sorry.
I guess I'm stuck on how to create the lists.
am I supposed to use arrays? I'm just not sure.
and how is one supposed to be ordered, and the other not?
that's the part that is confusing me.

felgall
12-01-2012, 06:16 AM
-All of the tags necessary to create a basic web page
-Your name in the TITLE and BODY of the page
-two LISTs (one ordered, one non-ordered) of:
1. an assignment summary and
2. your challenges in completing the assignment


Those are all just HTML - no JavaScript involved.


-JavaScript that performs an age calculation. The script should
-Prompt the user for a date of birth (at least year and month)

to collect that information you need a form - again that's just HTML.


-Display the month and year entered by the user
-Display the current date (use the Date() object)

The easiest way for beginners to update a web page with output from JavaScript is using a div with an id and then using getElementById to reference it and innerHTML to replace its content. Take a look at the "hello world" example in the link in my signature for how to do this - it is lesson ONE in writing JavaScript.

The Date object is probably the hardest part of this for a beginner - you need to know what Date methods to use to set and get dates and parts of dates.


-Calculates and displays the (approximate?) age difference in Years, months
-Prints out "Happy Birthday" and counts each line for each year of age (use a loop!)

Those are the actual calculations that you need to perform in JavaScript before outputting anything. If you know how to add and subtract and do loops in JavaScript then that part should be easy but if you haven't been paying attention in class then you will not know how to do it. See the link in my signature for live examples of how to do those sorts of thing in JavaScript.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum