Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Need help with JavaScript!

  • 05-12-2006 10:25PM
    #1
    Closed Accounts Posts: 30


    I am an amateur, having some trouble with my javascript, I am trying to make a app that can tell you what year was a leap year ad what year wasnt.
    As I have only started learning JavaScript last night I might not the greatest.
    I was thinking that if I could get a operator that is odd or even that might help. So if anyone could advise me and help clean it up a bit that would be great

    Help would really be appreciated.
    <html>
    <head>
    <script type="text/javascript">
    var leap = 4 
    alert("Click OK")
    
    var yes  = prompt("Enter a year to find out if that year was a leap year", "4")
    
    leap     *= parseInt(yes)
    alert("Even number= Leap year" + '\n' + "odd numbers=not a leap year" + '\n' + "OK go" + leap + "!!")
    </script>
    </head>
    <body>
    </body>
    </html>
    


Comments

  • Registered Users, Registered Users 2 Posts: 32,132 ✭✭✭✭is_that_so


    An explanation on Leap Years. You might want to look at mod or remainder. E.g. 20 % 2=0
    Google for "javascript examples tutorials" . Tons of stuff out there.


  • Closed Accounts Posts: 30 as_seen_on


    is_that_so wrote:
    An explanation on Leap Years. You might want to look at mod or remainder. E.g. 20 % 2=0
    Google for "javascript examples tutorials" . Tons of stuff out there.
    could you show me what you mean by 20 % 2=0, I dont really understand the % part.


  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    as_seen_on wrote:
    could you show me what you mean by 20 % 2=0, I dont really understand the % part.
    The modulo operator (%) divides the two numbers and returns the remainder, such as 20%2=0 above, or 14%5=4 (5 goes into 14 twice with 4 remaining), etc.


  • Registered Users, Registered Users 2 Posts: 32,132 ✭✭✭✭is_that_so


    Opps sorry. Assuming too much.:o


  • Closed Accounts Posts: 4 boondog


    Divide the given 4-digit year by 4 and/or 400. Any result where rest = zero is a leapyear.


  • Advertisement
Advertisement