Binary Tactics javascript implementation #2