I have a question about setting boolean conditions for data retrieved from an array. Here is the code snippet:
for (var k in GexfJS.graph.edgeList) {
var _edge = GexfJS.graph.edgeList[k]
if ( (_edge.source == _curre) && ( _edge.target != _nodeIndex) ) {
var _node = GexfJS.graph.nodeList[_edge.target];
//action
}
}
In the algorithm above, I want to set a condition for each _edge.target. If a certain action is taken, it should change a variable check to true (boolean condition).
For example:
var check = false;
for (var k in GexfJS.graph.edgeList) {
var _edge = GexfJS.graph.edgeList[k]
if ( (_edge.source == _curre) && ( _edge.target != _nodeIndex) && (check != true) ) {
var _node = GexfJS.graph.nodeList[_edge.target];
//action
check = true;
}
}
The issue is that the check
condition does not consistently apply to the _edge.target
.