chore(curriculum): adding content for booleans review page (#57195)

This commit is contained in:
Jessica Wilkins
2024-11-18 08:22:16 -08:00
committed by GitHub
parent 7b885c0c3d
commit f1befb8b6d
2 changed files with 51 additions and 1 deletions

View File

@@ -2590,7 +2590,8 @@
"review-javascript-comparisons-and-conditionals": {
"title": "JavaScript Comparisons and Conditionals Review",
"intro": [
"Review the JavaScript Comparisons and Conditionals concepts to prepare for the upcoming quiz."
"Before you are quizzed on working with conditionals, you first need to review.",
"Open up this page to review how to work with <code>switch</code> statements, other types of conditionals and more."
]
},
"quiz-javascript-comparisons-and-conditionals": {

View File

@@ -9,7 +9,56 @@ dashedName: review-javascript-comparisons-and-conditionals
Review the concepts below to prepare for the upcoming quiz.
## Comparisons and the `null` and `undefined` Data Types
- **Comparisons and `undefined`**: A variable is `undefined` when it has been declared but hasn't been assigned a value. It's the default value of uninitialized variables and function parameters that weren't provided an argument. `undefined` converts to `NaN` in numeric contexts, which makes all numeric comparisons with `undefined` return `false`.
```js
console.log(undefined > 0); // false
console.log(undefined < 0); // false
console.log(undefined == 0); // false
```
- **Comparisons and `null`**: The `null` type represents the intentional absence of a value. When using the equality operator, `null` and `undefined` are considered equal. However, when using the strict equality operator (`===`), which checks both value and type without performing type coercion, `null` and `undefined` are not equal:
```js
console.log(null == undefined); // true
console.log(null === undefined); // false
```
## `switch` Statements
- **Definition**: A `switch` statement evaluates an expression and matches its value against a series of `case` clauses. When a match is found, the code block associated with that case is executed.
```js
const dayOfWeek = 3;
switch (dayOfWeek) {
case 1:
console.log("It's Monday! Time to start the week strong.");
break;
case 2:
console.log("It's Tuesday! Keep the momentum going.");
break;
case 3:
console.log("It's Wednesday! We're halfway there.");
break;
case 4:
console.log("It's Thursday! Almost the weekend.");
break;
case 5:
console.log("It's Friday! The weekend is near.");
break;
case 6:
console.log("It's Saturday! Enjoy your weekend.");
break;
case 7:
console.log("It's Sunday! Rest and recharge.");
break;
default:
console.log("Invalid day! Please enter a number between 1 and 7.");
}
```
# --assignment--