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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Mar 2003
    Posts
    165
    Thanks
    0
    Thanked 0 Times in 0 Posts

    if else statment syntax

    hi, a beginner question, i can use and in an if statement like so:
    if (time>=10 && time<16)

    how can i say or:

    if (time>=10 or time<16)

    thanks

  • #2
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,696
    Thanks
    0
    Thanked 232 Times in 227 Posts
    Hi there havey,

    Why do you want to say...
    if (time>=10 or time<16)
    ...as this would include all values of time.
    if (time>=10 && time<16)
    Will provide the values of time 10 to 15 inclusive.

    coothead

  • #3
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,505
    Thanks
    3
    Thanked 501 Times in 488 Posts
    as coothead points out, does not make much sence in your example but

    the Javascript symbol for or is ||

    if (time>=10 || time<16)
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

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