mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-07 10:59:05 +08:00
Update CONTRIBUTING.md
This commit is contained in:
@ -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'
|
||||||
|
Reference in New Issue
Block a user