#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    40
    Rep Power
    1

    How to take a number and give it a value.


    I recently posted a question regarding how to find a percentage. I got my answer and now I am trying to find out how I would give the number a letter value. For example if a grade is 97 then the value is an A+ I'm just not sure how to go about it. Do I need to use an array? Any help would be appreciated.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    101
    Rep Power
    27
    why can't you just write simple conditional logic like
    Code:
    var letterval = 'F'; // you fail by default, like in life
    if (numberval > 95) letterval = 'A+';
    else if (numberval > 90) letterval = 'A';
    else if (numberval > 80) letterval = 'B';
    else if blah blah blah
    Adjust the number of conditionals and the integer comparisons to suit your needs

IMN logo majestic logo spyfu logo threadwatch logo seochat tools logo