About 90 minutes
- 10 minutes for video walkthrough of slides
- 75 minutes for Independent Practice
"JavaScript 4" lesson
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 switch statements (video)
- Switch statements (video) by FreeCodeCamp
- JavaScript switch statements (video)
- Switch statement docs (MDN)
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
Instructor demonstrates in the video walkthrough how to work with numbers and strings in JavaScript.
Techtonica staff will assign pairs.
Activity #1
Complete this HackerRank challenge which deals with a simple switch statement.
Activity #2
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).
Activity #3
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).