Thursday 10 August 2017

True but not...

Hi guys,So I have this code:User.getUserById(userID, function(err,user){ console.log("going"); if(err){ console.log(err); } //assign the user to a variable to hold the user data to make the variable in the form we want var userTemp = user; //create a variable to hold the users assets var assets = userTemp.assets; var name; //Go through the assets until we find the one with the same id as that post in the patch request body for(i = 0; i < assets.length-1; i++){ //Same id so same asset console.log(assets[i]._id); console.log(assetID); if(assets[i]._id == assetID){ console.log("match"); name = asset[i].name; //Set the asset variable coordiantes to that which where passed in the post request assets[i].location.coordinates = coordsArray; //Add these to the past array and add the date so I can get past hour/day/week/month assets[i].past.push({ numbers: [secondCord,firstCord], date: new Date(Date.now()) }); } } }); but the output is this:2017-08-10T22:33:41.211147+00:00 app[web.1]: 595e9c411fa2bd0011a33cfd 2017-08-10T22:33:41.211053+00:00 app[web.1]: 595e9c411fa2bd0011a33cff 2017-08-10T22:33:41.211070+00:00 app[web.1]: 595e9c411fa2bd0011a33cfe 2017-08-10T22:33:41.211163+00:00 app[web.1]: 595e9c411fa2bd0011a33cfe 2017-08-10T22:33:41.211556+00:00 app[web.1]: 595e9c411fa2bd0011a33cfb 2017-08-10T22:33:41.211573+00:00 app[web.1]: 595e9c411fa2bd0011a33cfe So the second run through should evaluate to true but it doesn't, any ideas why?Thanks, Ed.

Submitted August 10, 2017 at 11:38PM by thelynched

No comments:

Post a Comment