# Coding Conventions (Rules)

Every programming language, development environment, business, and person has their own opinion of how to write *readable* code. Without a set of rules, reading your colleague's code would be difficult. It is important to make code easy to read because someone else might need to use or improve it - and that's ok!

Most programmers have very specific rules for code style. Ours are simple:

* Variable and Function names will be *meaningful* and complete.
* Variable and Function names will only start with lowercase letters.
* Variables and Functions will be named using [**camelCase**](https://en.wikipedia.org/wiki/Camel_case)**.**
* Constants are written in all UPPERCASE letters.
* You will put spaces after commas, and around operators ( **`+ - * /`** ).
* *Always use 2 or 4 spaces to indent code blocks (our default is 2)*\
  (tabs are interpreted differently, depending on the text editor).\
  Example:\
  `function toCelsius(fahrenheit) {`\
  &#x20;   `return (5 / 9) * (fahrenheit - 32);`\
  `}`
* Always end single lines of code with a semicolon;
* Place opening brackets at the end of the current line, preceded by a single space.
  * Closing brackets are placed on their own line without leading spaces.\
    `for (i = 0; i < 5; i++) {      // Opening bracket`\
    &#x20;   `x += i;`\
    `}                              // Closing bracket`
* Hyphens are not permitted in names, use underscore instead.

For more on this topic:

{% embed url="<https://www.w3schools.com/js/js_conventions.asp>" %}

{% embed url="<https://en.wikipedia.org/wiki/Programming_style>" %}
