Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6038257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:11:35+00:00 2026-05-23T06:11:35+00:00

I have this following if statement: RG is 100 and max is 85 if

  • 0

I have this following if statement:

RG is “100” and max is “85”

if (RG == "" | RG > max) {
            //Doesn't execute
        }

Since RG isn’t “” and RG is larger than max why isn’t the code executing? I believed the operator was short circuiting (hence only the one pipe |) but changing it didn’t make any difference. My guess is that it is comparing literal strings – so how do I force javascript to treat them as floats?

Just to be clear I need both parts of the OR to be checked and only execute if either of them is true.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:11:36+00:00Added an answer on May 23, 2026 at 6:11 am

    I believed the operator was short circuiting (hence only the one pipe |) but changing it didn’t make any difference

    I take it then it originally looked like this:

    if (RG == "" || RG > max) {
        //Doesn't execute
    }
    

    We can ignore the first part because it’s false, so your question is why wasn’t RG > max true? And the answer is that “100” comes before “85” in the string collation order. Strings are not numbers, you don’t compare them numerically.

    If you want them to be floats as you said, you can make them numbers via parseFloat (or parseInt as they look like integers, but you said floats, so…):

    if (RG == "" || parseFloat(RG) > parseFloat(max)) {
        //Doesn't execute
    }
    

    I’ve done it inline there, but the odds seem high you’ll want to do it earlier and assign the result to variables, unless this really is the only place you’ll use the values as numbers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this problem with C. I have the following statement. int *a; a=malloc(100);
I am having trouble with the following SQL statement. I have had this issue
I have this following jquery text fly-in animation.Here is my code before I explain
I have this following code, here CssClass is of the String type. <asp:Panel ID=Panel1
I have the following code: float valueCalculated = (val1 / val2) * 100; What
I wrote the following code, which answers differently when I have printing statement and
I'm using the following statement int[] numList = ArrayUtil.randomIntArray(100, 100); and I have imported
Is this possible at all? The idea is to have the following: if ($some_statement)
I have this following codes: @implementation MyImageView @synthesize image; //image is a UIImage -
i have this following html structure usilg ul and li. <ul class=treeview id=productTree> <li

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.