Skip to content

Instantly share code, notes, and snippets.

@jfraboni
Last active February 19, 2019 10:30
Show Gist options
  • Save jfraboni/c79f19d235c392b30adcb1363fdebf46 to your computer and use it in GitHub Desktop.
Save jfraboni/c79f19d235c392b30adcb1363fdebf46 to your computer and use it in GitHub Desktop.
// More Efficient
function compareAll(bodies) {
// loop thru all bodies backwards : ignore first item //
for(let i = active.length - 1; i > 0; i--) {
// pull out bodyA for comparison //
const bodyA = active[i];
// loop thru all bodies backwards : start at j = i - 1 and include first item //
for(let j = i - 1; j > -1; j--) {
// pull out bodyB for comparison //
const bodyB = active[j];
// ompare bodyA to bodyB...
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment