How do i destroy all matter objects in a for loop?

Hello, I’m following this chain example as on the phaser examples website, but I cannot destroy the chain at all. Normally I’d make the ball a group and then call something like ‘group.getChildren().map(child => child.destroy());’ but u cannot make matter sprites part of a group as far as I know, and calling destroy() on the ball only removes one. The joint will not remove either, calling ‘this.matter.composite.remove(joint, this);’. How do you destroy this chain?! I’ve tried many things and spent way too much time on this small detail. This is the example I’m referring to:

You can add Matter sprites to a group, and destroy them the regular way. Idk how to remove the joints though.

I solved this by declaring a ‘const joints = [];’ at the top of create. Inside the for loop that creates the balls and joints, after ‘this.joint = this.matter.add.joint();’ call ‘joints.push(this.joint)’ and when i want to remove them, make another for loop to iterate over them again. ‘for (let i = 0; i < joints.length; i++) { this.matter.world.remove(joints[i]);’