课程: JavaScript Essential Training
今天就学习课程吧!
今天就开通帐号,24,600 门业界名师课程任您挑!
Conditional switch statement
- [Instructor] The if else statement is a useful tool, but in many cases it's not the right tool for the job. Let's say you want to output different values depending on how old the backpack is. So if it's under 30 days old, it's new. If it's under one year old, it's lightly used. If it's one year or older, it's used. And if it's more than three years old, it's old. We could do this by nesting conditional statements inside one another. But as you can see from the code example it gets clunky and hard to read. Here we're saying, if the age is over 30, and if the age is over 365, and if the age is over 1095, then it's old. Otherwise it's used, otherwise it's lightly used. Otherwise it's new. This is not only hard to write, it's also hard to read. Instead, when we want to get different results depending on various conditions, we can use a switch statement. Here if we look at the code example, we provide an…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。
内容
-
-
-
-
-
-
-
-
-
-
The real-world function2 分钟 49 秒
-
(已锁定)
Functions and methods6 分钟 23 秒
-
(已锁定)
A standard function3 分钟 53 秒
-
(已锁定)
The arrow function4 分钟 49 秒
-
(已锁定)
Arrow functions and "this"4 分钟 20 秒
-
(已锁定)
Practice: Build a function1 分钟 31 秒
-
(已锁定)
Pass data to a function with parameters4 分钟 56 秒
-
(已锁定)
Return values from a function7 分钟 1 秒
-
(已锁定)
Practice: Pass values between functions2 分钟 33 秒
-
(已锁定)
Callbacks5 分钟 29 秒
-
(已锁定)
Conditional if...else statement5 分钟 52 秒
-
(已锁定)
Logical operators3 分钟 31 秒
-
(已锁定)
Conditional switch statement5 分钟 55 秒
-
(已锁定)
Looping through content5 分钟 19 秒
-
(已锁定)
Using the map() array method4 分钟 52 秒
-
(已锁定)
Challenge intro: Create a content factory2 分钟 36 秒
-
(已锁定)
Solution: Create a content factory5 分钟 21 秒
-
-
-
-