Conditionals
(1) Intro to Conditionals
(2) Quiz: Flowcharts
(3) Flowchart to Code & (4) If…Else Statements
Flowchart to code can be done through if-else statements. If we want to determine if we have enough money to buy an object we can translate that into an if else statement through code. We’ll create two variables, the price of the object and how much money we have and use an if-else statement to have the code determine the decision for us.
var price = $15; //the price of the hammer
var money = $20; //how much money we have
if (money>=price) {
console.log('buy the hammer');
} else {
console.log('don't buy the hammer');
}
(5) Else If Statements
Else if statements allow you to create more complex decision flow charts. You can have multiple decision points that are sequentially evaluated until the right condition is met.
(6) Quiz: Even or Odd – Couldn’t solve
(7) Quiz: Musical Groups
(8) Quiz: Murder Mystery – Couldn’t solve
(9) More Complex Problems
(10) Logical Operators
(11) Logical AND and OR
Pingback: Udacity – Javascript – Lesson 2 – MilliardCo.