About 90 minutes
- 15 minutes for lesson
- 75 minutes for Independent Practice
- 30 minutes for Check for Understanding
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.
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
- when to use a switch statement
- switch syntax
JavaScript 5 (Video walkthrough of lesson slides)
- 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.
-
You need a
break
statement at the end of eachcase
. -
There is no comparison operator in a switch statement, but there is one in the if/else statement
Techtonica staff will assign pairs.
Refer back to the calculator activity from the JavaScript 1 lesson. Refactor your code to replace your if/else statement(s) with switch statement(s).
Refer back to the movie night activity from the JavaScript 3 lesson. Refactor your code to replace your if/else statement(s) with switch statement(s).
- JavaScript switch statements (video)
- Switch statements (video) by FreeCodeCamp
- JavaScript switch statements (video)
- Switch statement docs (MDN)
- 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.
Complete these HackerRank Challenges:
- HackerRank challenge: Switch which deals with a simple switch statement.
- Conditional Statements: Switch