Javascript push for loop

I am trying to find a match and each time a match is found I want it to be pushed to the already exsisting array.

var matchSource=edgesArray.find(edges => edges.source === nodeId); // returns edge

	                         		var findTargetNode=nodesArray.find(nodes=>;


		                        		for (var i = 0; i < edgesArray.length; i++) {

Well, you’ll want to check whether the objects are undefined before pushing them into the arrays.

Aside from that… what part of what you’ve provided doesn’t work?

I’m not at all familiar with the sigma graph objects, which this seems to be a continuation of, but that for loop looks pretty suspicious to me as well.

@m_hutley take over!

So let’s do a recap, so that I’m not the only person able to help. :wink: There’s a lot of undefined variables here that people need to know about.

How are we defining edgesArray, nodesArray, edges, and data?

Also, are you trying to find a singular edge, or multiple edges? Cause you’ve got code that looks like it’s expecting both - the first bit for a singular edge, the for loop for multiple.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.