Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #37981

Re: Logical conundrums if () else if()

From "R.Wieser" <address@not.available>
Newsgroups comp.lang.javascript
Subject Re: Logical conundrums if () else if()
Date 2019-12-28 12:21 +0100
Organization Aioe.org NNTP Server
Message-ID <qu7drc$frb$1@gioia.aioe.org> (permalink)
References <cd84bfc2-63ac-4a4f-bd76-9b144035b9ba@googlegroups.com>

Show all headers | View raw


Jonas,

> How can two if statements that work perfectly standalone as
> single statments. Make outcome that differs when you put in,
> an else if statement to only execute one of them.

Exactly like you've already shown (on other words: whats the problem ?)

> The below statements have the statement with heavier conditioning
> first so not the second statement gets executed.

Thats how you should do it, yes.

> Because both satisfy the noneboolean condition.

That does not make sense: /ALL/ conditions are boolean.

> I probably done some very no no thingy.

I still have no idea what your problem is (other than a very vage notion 
that /probably/ something doesn't quite work like it should - but I'm not 
even sure of that ...)

Suggestion: SIMPLIFY THE PROBLEM.

After you put the problem into its own HTML file replace the "do this" and 
"do that" with something you can easily check, like putting up message boxes 
with a different text for the above.    Replace the condition with simpler 
versions.  Like

(EDITEND<SELEND && document.getElementById("lockedit").checked)

with (something like)

( 5 < 7 && true)

Now you can easily see *and alter* what the condition is.

You might want to see if  "( (5 < 7) && true)" works better (read: check if 
"<" has a higher priority than "&&")

Writing programs is easy. The really hard part is to hunt bugs. :-)

Regards,
Rudy Wieser

P.s.
If-and-when you have a problem start with printing the "values" you are 
comparing as well as the comparision itself.  Like a message box just above 
that code example of yours displaying this:

alert( EDITEND +" , "+ SELEND +" , "+ 
document.getElementById("lockedit").checked +" = "+ (EDITEND<SELEND && 
document.getElementById("lockedit").checked) );

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Logical conundrums if () else if() Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-12-28 00:40 -0800
  Re: Logical conundrums if () else if() "R.Wieser" <address@not.available> - 2019-12-28 12:21 +0100
    Re: Logical conundrums if () else if() Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-12-28 05:32 -0800
      Re: Logical conundrums if () else if() "R.Wieser" <address@not.available> - 2019-12-28 19:10 +0100
        Re: Logical conundrums if () else if() Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-12-28 12:16 -0800
          Re: Logical conundrums if () else if() "R.Wieser" <address@not.available> - 2019-12-29 08:52 +0100
          Re: Logical conundrums if () else if() Arno Welzel <usenet@arnowelzel.de> - 2019-12-30 21:35 +0100
            Re: Logical conundrums if () else if() Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-12-30 12:42 -0800
  Re: Logical conundrums if () else if() "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2019-12-28 09:37 -0800
    Re: Logical conundrums if () else if() Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2019-12-29 11:43 +0100
      Re: Logical conundrums if () else if() "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2019-12-29 08:14 -0800
  Re: Logical conundrums if () else if() Soviet_Mario <SovietMario@CCCP.MIR> - 2020-01-18 21:06 +0100
    Re: Logical conundrums if () else if() Soviet_Mario <SovietMario@CCCP.MIR> - 2020-01-19 01:22 +0100

csiph-web