This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Quadratic time complexity O(N 2 ) — “Order N squared” | |
function compareAll(active) { | |
// loop thru all bodies backwards // | |
for(let i = active.length - 1; i > -1; i--) { | |
// pull out bodyA for comparison // | |
const bodyA = active[i]; | |
// loop thru all bodies backwards again // | |
for(let j = active.length - 1; j > -1; j--) { | |
// pull out bodyB for comparison // | |
const bodyB = active[j]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Updates the x and y properties of a body based on its | |
* velocityX and velocityY, and, updates the rotation of | |
* a body based on its rotationalVelocity. | |
* | |
* @param {Object} body: The body must be an Object | |
* with x, y, rotation, velocityX, velocityY, and | |
* rotationalVelocity properties. | |
*/ | |
updatePosition(body) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Updates the diagonal velocity properties of a body, | |
* taking into account the body's current velocity | |
* and applying any forces acting against the body | |
* as acceleration on both the x and y axis. | |
* | |
* NOTE: This method DOES NOT update the position of | |
* the body, it only updates its velocity. | |
* | |
* @param {Object} body: The body must be an Object |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": 641093, | |
"requirementId": "JHFvd2DnH9wTkLKXT", | |
"sessionId": "snXgTXcxPKdCQgTh3", | |
"type": "PROJECT", | |
"tests": 16, | |
"passes": 15, | |
"failures": 1 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* VARIABLES: | |
* | |
* 0. To hold things in memory during the life-cycle of a program, we can use variables. Variables | |
* are named identifiers that can point to values of a particular type, like a Number, String, | |
* Boolean, Array, Object or another data-type. Variables are called so because once created, we | |
* can CHANGE the value (and type of value) to which they point. | |
* | |
* 1. To create a variable we use the keyword, var, followed by a name (id or alias) for our | |
* variable. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* VARIABLES: | |
* | |
* 0. To hold things in memory during the life-cycle of a program, we can use variables. Variables | |
* are named identifiers that can point to values of a particular type, like a Number, String, | |
* Boolean, Array, Object or another data-type. Variables are called so because once created, we | |
* can CHANGE the value (and type of value) to which they point. | |
* | |
* 1. To create a variable we use the keyword, var, followed by a name (id or alias) for our | |
* variable. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* VARIABLES: | |
* | |
* 0. To hold things in memory during the life-cycle of a program, we can use variables. Variables | |
* are named identifiers that can point to values of a particular type, like a Number, String, | |
* Boolean, Array, Object or another data-type. Variables are called so because once created, we | |
* can CHANGE the value (and type of value) to which they point. | |
* | |
* 1. To create a variable we use the keyword, var, followed by a name (id or alias) for our | |
* variable. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
suite("strings", function(){ | |
test("toDashCase", function(done){ | |
expect(toDashCase('Hello World')).to.equal('hello-world'); | |
expect(toDashCase('Should Work With Many Words')).to.equal('should-work-with-many-words'); | |
done(); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
// variables |
NewerOlder