Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add [Conditonals] to Table of Contents #361

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 40 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -4,16 +4,18 @@

1. [Introduction](#introduction)
2. [Variables](#variables)
3. [Functions](#functions)
4. [Objects and Data Structures](#objects-and-data-structures)
5. [Classes](#classes)
6. [SOLID](#solid)
7. [Testing](#testing)
8. [Concurrency](#concurrency)
9. [Error Handling](#error-handling)
10. [Formatting](#formatting)
11. [Comments](#comments)
12. [Translation](#translation)
3. [Conditionals](#conditionals)
4. [Functions](#functions)
5. [Objects and Data Structures](#objects-and-data-structures)
6. [Classes](#classes)
7. [SOLID](#solid)
8. [Testing](#testing)
9. [Concurrency](#concurrency)
10. [Error Handling](#error-handling)
11. [Formatting](#formatting)
12. [Comments](#comments)
13. [Translation](#translation)


## Introduction

@@ -227,6 +229,34 @@ function createMicrobrewery(name = "Hipster Brew Co.") {

**[⬆ back to top](#table-of-contents)**


## **Conditionals**

### Use ternary operators to set a value to a variable, or to reduce code if necessary. Use if-else statements for everything else.

**Bad:**

```javascript
function getFee(isMember) {
if(isMember){
return '$4.00';
}
else {
return '$12.00'
}
}
```

**Good:**

```javascript
function getFee(isMember) {
return (isMember ? '$4.00' : '$12.00');
}
```

**[⬆ back to top](#table-of-contents)**

## **Functions**

### Function arguments (2 or fewer ideally)