Skip to content

Commit

Permalink
Merge pull request #1833 from mx-ruthie/patch-35
Browse files Browse the repository at this point in the history
Update javascript-5-switch.md
  • Loading branch information
Yosolita1978 authored Feb 2, 2023
2 parents cd3dd04 + b299234 commit ba771b2
Showing 1 changed file with 8 additions and 28 deletions.
36 changes: 8 additions & 28 deletions javascript/javascript-5-switch.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# JavaScript 5 - Switch Statements

### Projected Time
### Week 3 Keywords and Questions

About 60 minutes
- What is a switch statement, when would I use one?
- Why a switch statement over an if/else?
- What is the syntax of a switch statement?
- What is the “break” part of a switch statement, and what will happen if no break statement is used?

- 15 minutes for lesson
- 30 minutes for Independent Practice
- 15 minutes for Check for Understanding

### Prerequisites

Expand All @@ -16,12 +16,6 @@ About 60 minutes

JavaScript is used on the frontend of almost every website. It's also a widely-used scripting language that be used on the backend as well. The JavaScript lessons set a solid foundation in JavaScript basics so we can use the language in more robust ways in later lessons.

### Objectives

**Participants will be able to:**

- Know when to use a switch statement instead of an if/else statement
- Write a switch statement using proper syntax

### Specific Things to Learn

Expand All @@ -32,10 +26,6 @@ JavaScript is used on the frontend of almost every website. It's also a widely-u

[JavaScript 5 (Video walkthrough of lesson slides)](https://drive.google.com/file/d/1x5U0jFgEZD-NjOnfoZ_mkYZpXoODbMIS/view?usp=sharing)

- Please watch the video the first time without working along with the demonstration. Just absorb the concepts. Then, you can watch the demonstration a second time and code with the instructor if you like.

### Materials

[JavaScript 5 - Switch Statements (slides)](https://docs.google.com/presentation/d/1hmP5pOfrgexspDS827_cGkb3SNqhIJnbxrlnRFcHCGw/edit?usp=sharing)

### Common Mistakes / Misconceptions
Expand All @@ -44,13 +34,6 @@ JavaScript is used on the frontend of almost every website. It's also a widely-u

- **There is no comparison operator in a switch statement, but there is one in the if/else statement**

### Independent Practice

Refer back to the [calculator activity](../javascript/javascript-1-variables.md#independent-practice) from the JavaScript 1 lesson. Refactor your code to replace your if/else statement(s) with switch statement(s).

### Challenges

Refer back to the [movie night activity](../javascript/javascript-3-conditionals.md#independent-practice) from the JavaScript 3 lesson. Refactor your code to replace your if/else statement(s) with switch statement(s).

### Supplemental Materials

Expand All @@ -59,14 +42,11 @@ Refer back to the [movie night activity](../javascript/javascript-3-conditionals
- [JavaScript switch statements (video)](https://www.youtube.com/watch?v=Z6O_XdfCBEo)
- [Switch statement docs (MDN)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch)

### Check for Understanding
### Additional Challenges

- Write down the syntax of a switch statement in JavaScript.
- What will happen if break is not used in a switch statement?
- What is the advantage of using a switch statement over an if/else statement?
- Using a switch statement, write a program to accept a lower case letter. Create an alert with the text 'This letter is a vowel' if the letter is a vowel.
If you have previously completed it, refer back to the [calculator activity](../javascript/javascript-1-variables.md#independent-practice) from the JavaScript 1 lesson. Refactor your code to replace your if/else statement(s) with switch statement(s).

### Extensions
If you have previously completed it, refer back to the [movie night activity](../javascript/javascript-3-conditionals.md#independent-practice) from the JavaScript 3 lesson. Refactor your code to replace your if/else statement(s) with switch statement(s).

Complete these HackerRank Challenges:

Expand Down

0 comments on commit ba771b2

Please sign in to comment.