From 886477cddf09d893a0be230f7157681a375a313a Mon Sep 17 00:00:00 2001 From: David MAECHLER Date: Mon, 6 Apr 2020 01:45:51 +0200 Subject: [PATCH] fix stupid error in for loop --- back/src/Controller/position.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/back/src/Controller/position.js b/back/src/Controller/position.js index 95a55134..605c1163 100644 --- a/back/src/Controller/position.js +++ b/back/src/Controller/position.js @@ -1,7 +1,7 @@ // Constants let MIN_DISTANCE = 12; let MAX_PER_GROUP = 3; -let NB_USERS = 4; +let NB_USERS = 10; // Utils let rand = function(min, max) { @@ -34,8 +34,6 @@ for(let i = 1; i <= NB_USERS; i++) { users.push(user); } -console.log(users); - // Compute distance between each user let getDistanceOfEachUser = function(users) { let i = 0; @@ -74,7 +72,7 @@ let createGroups = function(distances) { if(groups[i].indexOf(dist.first) === -1 && typeof alreadyInAGroup[dist.first.id] === 'undefined') { if(groups[i].length > 1) { - for(let l = 0; groups[i].length; l++) { + for(let l = 0; l < groups[i].length; l++) { let userTotest = groups[i][l]; if(computeDistance(dist.first, userTotest) <= MIN_DISTANCE) { groups[i].push(dist.first); @@ -99,7 +97,7 @@ let createGroups = function(distances) { if(groups[i].indexOf(dist.second) === -1 && typeof alreadyInAGroup[dist.second.id] === 'undefined') { if(groups[i].length > 1) { - for(let l = 0; groups[i].length; l++) { + for(let l = 0; l < groups[i].length; l++) { let userTotest = groups[i][l]; if(computeDistance(dist.second, userTotest) <= MIN_DISTANCE) { groups[i].push(dist.second); @@ -127,6 +125,7 @@ let groups = createGroups(distances); // TODO : Créer une méthode pour checker la distance entre les membres du groupes pour savoir s'il faut les dissoudre ou non +console.log(users); console.log(distances); console.log(groups);