fix a little error in logic of createGroups() method
authorDavid MAECHLER <d.maechler@thecodingmachine.com>
Sat, 4 Apr 2020 19:06:34 +0000 (21:06 +0200)
committerDavid MAECHLER <d.maechler@thecodingmachine.com>
Sat, 4 Apr 2020 19:06:34 +0000 (21:06 +0200)
back/src/Controller/position.js

index 8c445b1429308d448aa94fd852925dda5009d366..d8f6affad9a23056716115c6de4a1ce18ce81b3e 100644 (file)
@@ -55,7 +55,7 @@ let createGroups = function(distances) {
                 groups[i] = [];
             }
 
-            if(groups[i].indexOf(dist.first) && typeof alreadyInGroup[dist.first.id] === 'undefined') {
+            if(!groups[i].indexOf(dist.first) && typeof alreadyInGroup[dist.first.id] === 'undefined') {
                 groups[i].push(dist.first);
                 alreadyInGroup [dist.first.id] = true;
             }
@@ -69,7 +69,7 @@ let createGroups = function(distances) {
                 continue;
             }
 
-            if(groups[i].indexOf(dist.second) && typeof alreadyInGroup[dist.second.id] === 'undefined') {
+            if(!groups[i].indexOf(dist.second) && typeof alreadyInGroup[dist.second.id] === 'undefined') {
                 groups[i].push(dist.second);
                 alreadyInGroup [dist.second.id] = true;
             }