Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 93a311f

Browse files
committed
Add Formatting section
1 parent dfe15ca commit 93a311f

File tree

1 file changed

+40
-36
lines changed

1 file changed

+40
-36
lines changed

README.md

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ readable, reusable, and refactorable software in JavaScript. Enjoy!
1010
3. [Objects and Data Structures](#objects-and-data-structures)
1111
4. [Classes](#classes)
1212
5. [Concurrency](#concurrency)
13-
6. [Comments](#comments)
13+
6. [Formatting](#formatting)
14+
7. [Comments](#comments)
1415

1516
## **Variables**
1617
### Use meaningful and pronounceable variable names
@@ -93,41 +94,6 @@ locations.forEach((location) => {
9394
```
9495
**[⬆ back to top](#table-of-contents)**
9596

96-
### Use consistent capitalization
97-
JavaScript is untyped, so capitalization tells you a lot about your variables,
98-
functions, etc. These rules are subjective, so your team can choose whatever
99-
they want. The point is, no matter what you all choose, just be consistent.
100-
101-
**Bad:**
102-
```javascript
103-
var DAYS_IN_WEEK = 7;
104-
var daysInMonth = 30;
105-
106-
var songs = ['Back In Black', 'Stairway to Heaven', 'Hey Jude'];
107-
var Artists = ['ACDC', 'Led Zeppelin', 'The Beatles'];
108-
109-
function eraseDatabase() {}
110-
function restore_database() {}
111-
112-
class animal {}
113-
class Alpaca {}
114-
```
115-
116-
**Good**:
117-
```javascript
118-
var DAYS_IN_WEEK = 7;
119-
var DAYS_IN_MONTH = 30;
120-
121-
var songs = ['Back In Black', 'Stairway to Heaven', 'Hey Jude'];
122-
var artists = ['ACDC', 'Led Zeppelin', 'The Beatles'];
123-
124-
function eraseDatabase() {}
125-
function restoreDatabase() {}
126-
127-
class Animal {}
128-
class Alpaca {}
129-
```
130-
**[⬆ back to top](#table-of-contents)**
13197

13298
### Don't add unneeded context
13399
If your class/object name tells you something, don't repeat that in your
@@ -1005,6 +971,44 @@ async function getCleanCodeArticle() {
1005971
**[⬆ back to top](#table-of-contents)**
1006972

1007973

974+
## **Formatting**
975+
### Use consistent capitalization
976+
JavaScript is untyped, so capitalization tells you a lot about your variables,
977+
functions, etc. These rules are subjective, so your team can choose whatever
978+
they want. The point is, no matter what you all choose, just be consistent.
979+
980+
**Bad:**
981+
```javascript
982+
var DAYS_IN_WEEK = 7;
983+
var daysInMonth = 30;
984+
985+
var songs = ['Back In Black', 'Stairway to Heaven', 'Hey Jude'];
986+
var Artists = ['ACDC', 'Led Zeppelin', 'The Beatles'];
987+
988+
function eraseDatabase() {}
989+
function restore_database() {}
990+
991+
class animal {}
992+
class Alpaca {}
993+
```
994+
995+
**Good**:
996+
```javascript
997+
var DAYS_IN_WEEK = 7;
998+
var DAYS_IN_MONTH = 30;
999+
1000+
var songs = ['Back In Black', 'Stairway to Heaven', 'Hey Jude'];
1001+
var artists = ['ACDC', 'Led Zeppelin', 'The Beatles'];
1002+
1003+
function eraseDatabase() {}
1004+
function restoreDatabase() {}
1005+
1006+
class Animal {}
1007+
class Alpaca {}
1008+
```
1009+
**[⬆ back to top](#table-of-contents)**
1010+
1011+
10081012
## **Comments**
10091013
### Only comment things that have business logic complexity.
10101014
Comments are an apology, not a requirement. Good code *mostly* documents itself.

0 commit comments

Comments
 (0)