Skip to content

Commit

Permalink
formatting fixes and edits for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
lizbur10 committed Jan 22, 2021
1 parent 537d722 commit 36b681d
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# Control Flow Lab

## Problem Statement
## Learning Goals

In this code-along, we will practice working with control flow in JavaScript.

## Objectives

1. Practice writing `if...else if...else` statements.
2. Practice working with the ternary operator.
3. Practice writing `switch` statements.
* Practice writing `if...else if...else` statements.
* Practice working with the ternary operator.
* Practice writing `switch` statements.

## Introduction

Expand Down Expand Up @@ -53,8 +49,10 @@ now, briefly, a function declaration is written like so:

```js
function addFive(someNumber) {
//everything I want my function to do I put inside these curly braces
//in this example, let's say I want my function, addFive, to add 5 to any number I pass in (someNumber), but only IF the number is greater than zero
//Everything I want my function to do I put inside these curly braces
//In this example, let's say I want my function, addFive, to add 5 to
//any number I pass in (someNumber), but only IF the number is greater
//than zero:
let result
if (someNumber > 0) {
result = someNumber + 5;
Expand All @@ -63,16 +61,21 @@ function addFive(someNumber) {
return result
}

//once our function is declared, we can call addFive, passing in values as arguments
//once our function is declared, we can call addFive, passing in values
//as arguments:

addFive(10);
//returns 15
//=> 15

addFive(20);
//returns 25
//=> 25

addFive(-5);
//returns undefined
//=> undefined

addFive(addFive(5));
//returns 15!! In this case, the return value of addFive(5), 10, is passed in as the argument to the outer addFive, returning 15
//=> 15!! In this case, the return value of addFive(5), 10, is passed in
//as the argument to the outer addFive, returning 15
```

So, looking back at our test example, `scuberGreetingForFeet(199)` is calling
Expand Down Expand Up @@ -105,23 +108,24 @@ problem we are solving.
## Instructions

There are three functions that have been declared for you. You will need to fill in the following code:
* `scuberGreetingForFeet()` — Use `if` and `else if` statements to return the

* `scuberGreetingForFeet()` — Use `if` and `else if` statements to return the
correct greeting based on the distance the passenger desires to travel.
* `ternaryCheckCity()` Use a ternary operator to return the correct response
* `ternaryCheckCity()` — Use a ternary operator to return the correct response
based on the desired destination of the passenger.
* `switchOnCharmFromTip()` Use a `switch` statement to return a different
* `switchOnCharmFromTip()` — Use a `switch` statement to return a different
response based on the generosity of the passenger's tip.

***NOTE***: Beware a gotcha! In JavaScript, you cannot express the concept of
> **NOTE**: Beware a gotcha! In JavaScript, you cannot express the concept of
'between' in the following way:

```js
2 < 5 < 4
// => true
```

It seems like that expression should evaluate to `false` because `5` is not
less than `4`. However, we're forgetting about the order of operations let's
It seems like that expression should evaluate to `false` because `5` is not less
than `4`. However, we're forgetting about the order of operations &mdash; let's
think about how the JavaScript engine evaluates that expression. First, the
engine compares `2 < 5`, which evaluates to `true`. At that point, it's as
though the value `true` has replaced `2 < 5` in the expression, resulting in
Expand Down

0 comments on commit 36b681d

Please sign in to comment.