Helper method to check if 3 numbers match some of the valid results I have this helper method to check if 3 numbers match some of the valid results (XXX+bool, XXX, -XX, X-X, XX-, --X).

const categoryNumber = (numbers, myBool, resultNumbers) =&gt; {
  const matches = numbers.map((val, index) =&gt; val === resultNumbers[index]);
  if (matches[0] &amp;&amp; matches[1] &amp;&amp; matches[2] &amp;&amp; myBool) return 1;
  if (matches[0] &amp;&amp; matches[1] &amp;&amp; matches[2]) return 2;
  if (matches[0] &amp;&amp; matches[1]) return 3;
  if (matches[1] &amp;&amp; matches[2]) return 4;
  if (matches[0] &amp;&amp; matches[2]) return 5;
  if (matches[2]) return 6;
  return 0;
};


Type vars?:

numbers:       numeric array size 3
myBool:        boolean
resultNumbers: numeric array size 3
You could use a look up table, as follows:

var obj = { 'XXX': 2, '-XX': 3, 'X-X': 4, 'XX-': 5, '--X': 6}
var match = ""+ matches[0] + matches[1] + matches[2];


and then

if(match === 'XXX' &amp;&amp; myBool){ return 1; } else { return obj[match]; }


This assumes that each position in your matches will be either an X or a -.