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


Groups > comp.lang.javascript > #32348

Re: Handling multiple results from combinations

From Dr J R Stockton <reply1700@merlyn.demon.co.uk.invalid>
Newsgroups comp.lang.javascript
Subject Re: Handling multiple results from combinations
Date 2017-01-25 22:45 +0000
Organization Home
Message-ID <Beu5S02dqSiYFwq1@invalid.uk.co.demon.merlyn.invalid> (permalink)
References <B9OdnUTUM9EuUBvFnZ2dnUU7-dnNnZ2d@westnet.com.au>

Show all headers | View raw


In comp.lang.javascript message <B9OdnUTUM9EuUBvFnZ2dnUU7-dnNnZ2d@westne
t.com.au>, Tue, 24 Jan 2017 14:44:52, Andrew Poulos
<ap_prog@hotmail.com> posted:

>Say there are 10 options that can be selected in any order and each
>combination produces a different result. Is there some way to approach
>judging the options to choose the result without having such a tree
>full of IF statements:
>
>if (a && b && c...) {
>  //
>} else if (a && b && !c...) {
>  //
>} else if (a && !b && !c...) {
>  //
>} else if (!a && b && !c...) {
>  //
>} else if (!a && !b && !c...) {
>...
>
>Currently I'm working on an elearning question where there are multiple
>options and different combinations of selected options gives different
>feedback. There isn't 10! possible feedback but enough to make the
>building and testing of the question slow going.


You could maybe concatenate the booleans in a string as illustrated by
        var Q = "F" + +(1==1) + +(1==2) + +(1!=2)
then write functions for each case - function F101() { ... } for that -
and then merely execute   window[Q]()   // !!!     untested.  Lo, not an
"if" in sight.

-- 
 (c) John Stockton, Surrey, UK.  ¬@merlyn.demon.co.uk   Turnpike v6.05   MIME.
 Merlyn Web Site <                       > - FAQish topics, acronyms, & links.

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


Thread

Handling multiple results from combinations Andrew Poulos <ap_prog@hotmail.com> - 2017-01-24 14:44 +1100
  Re: Handling multiple results from combinations Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-24 05:34 +0100
    Re: Handling multiple results from combinations Andrew Poulos <ap_prog@hotmail.com> - 2017-01-24 16:54 +1100
      Re: Handling multiple results from combinations Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-24 07:14 +0100
  Re: Handling multiple results from combinations "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-01-23 22:31 -0800
    Re: Handling multiple results from combinations "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-01-24 11:27 +0100
      Re: Handling multiple results from combinations "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-01-24 16:41 -0800
        Re: Handling multiple results from combinations "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-01-25 11:17 +0100
          Re: Handling multiple results from combinations "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-01-25 05:19 -0800
            Re: Handling multiple results from combinations "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-01-25 06:25 -0800
            Re: Handling multiple results from combinations "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-01-25 17:37 +0100
              Re: Handling multiple results from combinations "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-01-25 08:47 -0800
  Re: Handling multiple results from combinations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-01-24 14:22 +0000
  Re: Handling multiple results from combinations Doc O'Leary  <droleary@2015usenet1.subsume.com> - 2017-01-24 20:17 +0000
    Re: Handling multiple results from combinations "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-01-24 16:47 -0800
  Re: Handling multiple results from combinations Dr J R Stockton <reply1700@merlyn.demon.co.uk.invalid> - 2017-01-25 22:45 +0000
    Re: Handling multiple results from combinations "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-01-25 17:53 -0800
      Re: Handling multiple results from combinations Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-26 23:21 +0100

csiph-web