# Reading Material JavaScript1 Week 2 ## Agenda These are the topics for week 2: 1. Statements vs. Expressions 2. Loops 3. Control Flow 4. Operators 5. Conditional statement 6. Naming conventions ## 1. Statements vs. Expressions A lot of programming is nothing different from regular human communication. When conversing with another person, we often use language in various ways: to ask questions, make statements or simply express yourself about what's going on. This is the same in programming. A difference is that it's done in abstract code. Another difference is that a programming statement is an instruction, while a programming expression leads directly to a value (and are usually different parts of a statement). To learn more about statements vs. expression, research the following resources: - [Statements vs. Expressions](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/statements_expressions.md) - [Expressions vs. Statements in JS](https://www.youtube.com/watch?v=WVyCrI1cHi8) ## 2. Loops A loop is a sequence of instructions that is continually repeated until a certain condition is fulfilled. This condition could either be a specified number or when a desired value is found. Read more about loops here: - [JavaScript Loops](https://www.youtube.com/watch?v=s9wW2PpJsmQ) - [Loops](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/loops.md) ## 3. Control Flow Almost all European languages are read from left to right. In Arabic and Hebrew this is the other way around: from right to left. In the language of JavaScript this goes from top to bottom, left to right. This is called the `control flow`: the order in which the computer executes statements in a script. The `control` parts refers to the ability to execute something by the computer, while the `flow` part refers to the causal chain between the execution of one action to another. > The term `flow` is a general term meaning a specific, repeatable order of actions. In your working life you'll hear the term `workflow`, which in that case refers to the different actions necessary to complete a business activity. There is one important distinction between spoken language and programming languages: in programming languages the order in which the code is read can change, depending on various `control statements`. Learn more about control flow here: - [Control flow](https://dev.to/mugas/control-flow-in-javascript-246l) ## 4. Operators If you've ever taken a mathematics class you are familiar with symbols like `+`, `-`, `/` and `=`. These symbols are recognized by the computer and are called `operators`. They can be used to perform calculations (with numbers) or to determine whether or not something is true (more on that in the next section). Check the following resources to learn more about their importance: - [Different Types of Operators in JavaScript](https://www.youtube.com/watch?v=FZzyij43A54) - [Operators](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/operators.md) ## 5. Conditional statement Computers only function by logical rules: whether something is true or not determines if an instructions gets executed or not. This logical process is expressed in a `conditional statement` and goes like this: if _this happens_, then _that happens_. Or in code: ```js if () { } ``` A condition is put in the `( )` and it needs to evaluate to `true` or `false` (also known as Boolean values). If the condition is true, then whatever is inside the `{ }` will be executed. What happens when the condition is false? For that we have the `else { }` block. If the condition is false, then whatever is inside the else will be executed: ```js if() { } else { } ``` ## 6. Naming conventions A naming convention is a rule that every developer should hold themselves to when creating variable or function names. This is important, because writing code should be done in a **readable** way: you should be able to understand what a certain variable or function does just by looking at its name. Read about the different naming conventions for JavaScript here: - [Naming conventions](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/naming_conventions.md) ## Finished? Are you finished with going through the materials? You're doing great! If you feel ready to get practical, click [here](./MAKEME.md).