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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Sep 2011
    Posts
    184
    Thanks
    140
    Thanked 0 Times in 0 Posts

    Number Based Priority System

    Hello,

    I need your help.

    How can I go about creating a priority system based on a given number

    ex.

    var n = 5
    var p = priority level

    If n is between 0 and 5 then p = "high"

    If n is between 5 and 10 then p = "medium"

    If n is between 10 and up then p = "low"

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,542
    Thanks
    77
    Thanked 4,381 Times in 4,346 Posts
    Ummm...

    Code:
    var p;
    if ( n < 0 ) { p = "invalid"; }
    else if ( n <= 5 ) { p = "high"; }
    else if ( n <= 10 ) { p = "medium" }
    else { p = "low"; }
    Did you really mean something that simple??? Or are you asking something completely different?

    If you prefer, you can change the <='s there to just <.

    As you wrote your message, exactly 5 might be either "high" or "medium", for example. So you choose.
    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.

  • Users who have thanked Old Pedant for this post:

    jason_kelly (07-11-2012)


  •  

    Posting Permissions

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