Update CONTRIBUTING.md

This commit is contained in:
vinayak
2020-05-03 17:56:44 +05:30
committed by GitHub
parent ea169a26e0
commit 90e13c0ad9

View File

@ -48,18 +48,29 @@ Algorithms in this repo should not be how-to examples for existing Javascript pa
#### Coding Style #### Coding Style
We want your work to be readable by others; therefore, we encourage you to note the following: We want your work to be readable by others; therefore, we encourage you to note the following:
- Must follow [JavaScript Standard Style](https://standardjs.com/)
- Command to install JavaScript Standard Style
```
$ npm install standard --save-dev
```
- Usage
```
$ standard
```
- Use camelCase for identifier names (variables and functions) - Use camelCase for identifier names (variables and functions)
- Names start with a letter - Names start with a letter
- follow code indentation - follow code indentation
- Always use 2 spaces for indentation of code blocks - Always use 2 spaces for indentation of code blocks
``` ```
function sumOfArray(arrayOfNumbers) { function sumOfArray (arrayOfNumbers) {
let sum = 0; let sum = 0
for (let i = 0; i < arrayOfNumbers.length; i++) { for (let i = 0; i < arrayOfNumbers.length; i++) {
sum += arrayOfNumbers[i]; sum += arrayOfNumbers[i]
} }
return (sum); return (sum)
} }
``` ```
- Avoid using global variables and avoid '==' - Avoid using global variables and avoid '=='
- use 'let' over 'var' - use 'let' over 'var'