Helper method to check if 3 numbers match some of the valid results
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 -.