Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with a JS assignment

    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/c...avascript2.png

    Any help would be appreciated. Thanks!

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,479
    Thanks
    6
    Thanked 981 Times in 954 Posts
    Let me cordially point you to rule # 1.5 of the forum rules.

    That said, what have you tried so far?

  • #3
    New to the CF scene
    Join Date
    Dec 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,471
    Thanks
    0
    Thanked 634 Times in 624 Posts
    Quote Originally Posted by Vonice View Post
    -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.

    Quote Originally Posted by Vonice View Post
    -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.

    Quote Originally Posted by Vonice View Post
    -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.

    Quote Originally Posted by Vonice View Post
    -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.
    Last edited by felgall; 12-01-2012 at 06:19 AM.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •