-
Notifications
You must be signed in to change notification settings - Fork 2
Code Conventions
Tomás Veras edited this page Apr 24, 2016
·
10 revisions
- Strive to keep lines under 120 chars (everyone hates horizontal scroll). Atom has a ruler which helps to identify where is the limit, go to settings and set Preferred Line Length to 120.
- If the code fits on one line and doesn't break our code conventions, strive to keep it on one line.
- We use 4 spaces indentation. Atom can do this just go to settings and set Tab Length to 4
let: the variable may be reassigned.
const: the variable can’t be reassigned.
We are using the Hungarian notation, Ex:
let carColor;
const houseDoorSize;
For the string we use simple quotes ' ', Ex:
const myName = 'Mike Wazowski';This how we're going to formatting our code. If one condition use brackets, all the conditions will need brackets too.
Ex #1:
if (condition) {
//Multiple lines
} else {
//One line
}Ex #2:
if (condition)
//One line
else
//One lineWe are using four-character indents, Ex:
if( car.id == 79){
car.color = blue;
var wheels = car.wheels;
}