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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jul 2013
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Exclamation need quick help w/ function composition before 3pm

    Hi, on a deadline, looking for a solution to this problem:

    The following functions are already defined for me...

    function currentYear() {
    var now = new Date();
    return now.getFullYear();
    }

    function currentMonth() {
    var now = new Date();
    return now.getMonth();
    }

    /*
    * Write a function that takes a year and a month and returns
    * a string describing how much time lies between than and today
    * like so:
    *
    * return "2 months and 24 years";



    Thanks for the help!

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,730
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    See forum rule #1.5 re homework assignments.

    It is your responsibility to die() if necessary….. - PHP Manual

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    Senior Coder jerry62704's Avatar
    Join Date
    Oct 2007
    Location
    Springfield, IL
    Posts
    1,100
    Thanks
    13
    Thanked 87 Times in 87 Posts
    Quote Originally Posted by javaj View Post
    Hi, on a deadline, looking for a solution to this problem:

    The following functions are already defined for me...

    function currentYear() {
    var now = new Date();
    return now.getFullYear();
    }

    function currentMonth() {
    var now = new Date();
    return now.getMonth();
    }

    /*
    * Write a function that takes a year and a month and returns
    * a string describing how much time lies between than and today
    * like so:
    *
    * return "2 months and 24 years";



    Thanks for the help!
    Consider what is returned with month (zero based) and good luck with your homework!
    .
    .
    ...and gladly would he learn and gladly teach

    Visit www.LiberalsWin.com for humor and the unique Bush/Obama Approval Polls

  • Users who have thanked jerry62704 for this post:

    javaj (07-03-2013)

  • #4
    New to the CF scene
    Join Date
    Jul 2013
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    sorry for the hwk post. rookie mistake. thanks jerry.

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    What's really funny is: *WHICH* 3PM???

    3PM in Australia? In that case, the message was posted after the deadline.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    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
    •