-
Notifications
You must be signed in to change notification settings - Fork 1
Code Documentation
ntrappe edited this page Mar 11, 2021
·
10 revisions
- 2 spaces
- IDs/classes should be hyphenated (e.g.
#timer-button
NOT#timerButton
)
- line width: 100 max
- 2 spaces
- variables:
-
let
is preferred overvar
- use
const
for global variables (generally for hard-coded values) and capitalize (e.g.const SEC_PER_MIN = 60
) - can use single character variables,
i, k, j
in loops only
-
- variables & functions should use camel case (e.g.
addTwoNumbers
NOTadd_two_numbers
) - variable IDs/classes should be hyphenated (e.g.
#timer-button
NOT#timerButton
)
Note the spacing between characters and placement of curly braces.
Loops:
for (int i = 0; i < len; i++) {
// do something
}
Functions:
const helloWorld = () => {
// do something
}
Conditionals:
if (var == 0) {
// do something
} else {
// do other thing
}
/**
* Add two numbers together
* @param {Number} num1 The first number
* @param {Number} num2 The second number
* @return {Number} The total of the two numbers
*/
function addTwoNumbers(num1, num2) {
return num1 + num2;
};