You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Context:
Throughout the course of this tutorial, I found converting all of the var variables with const or let variables (based on Airbnb's styleguide) was a great mental exercise . While many of these conversions were initially obvious (ex: Lives should almost always be let), many were not (ex: Should brickRowCount be let or const?).
Inevitably, for the less obvious variables - I found the best way to make a determination is to mentally go through your features and mentally identify which will change - shift those variable from (the default) const' to let`.
Discussion Point 1:
While the above method is thorough, it can take extra time. Are there any shortcuts used in industry to make a determination?
Discussion Point 2 :
How does this concept change when we are going through for loops?
Ex:
// Collision Detection (Brick)
function collisionDetection() {
for(var c=0; c<brickColumnCount; c++) {
for(var r=0; r<brickRowCount; r++) {
let b = bricks[c][r]
if(b.status == 1) {
if(x > b.x && x < b.x+brickWidth && y > b.y && y < b.y+brickHeight) {
dy = -dy;
b.status = 0;
score++;
if(score == brickRowCount*brickColumnCount) {
alert("YOU WIN, YOU ROCK!")
document.location.reload()
clearInterval(interval)
}
}
}
}
}
}
The text was updated successfully, but these errors were encountered:
(https://developer.mozilla.org/en-US/docs/Games/Tutorials/2D_Breakout_game_pure_JavaScript)
Context:
Throughout the course of this tutorial, I found converting all of the
var
variables withconst
orlet
variables (based on Airbnb's styleguide) was a great mental exercise . While many of these conversions were initially obvious (ex: Lives should almost always belet
), many were not (ex: Should brickRowCount belet
orconst
?).Inevitably, for the less obvious variables - I found the best way to make a determination is to mentally go through your features and mentally identify which will change - shift those variable from (the default)
const' to
let`.Discussion Point 1:
While the above method is thorough, it can take extra time. Are there any shortcuts used in industry to make a determination?
Discussion Point 2 :
How does this concept change when we are going through
for loops
?Ex:
The text was updated successfully, but these errors were encountered: