Questions and Answers Latest Update
Already Passed
What will the following code print?
```javascript
let x = 10;
if (x > 5) {
console.log("Greater");
}
```
✔✔ The output will be "Greater" because the condition `x > 5` is true.
What is the difference between `==` and `===` in JavaScript?
✔✔ `==` checks for equality after type conversion, while `===` checks for strict equality,
including the data type.
How do you create a `for` loop in JavaScript?
1
,✔✔ You create a `for` loop using the syntax `for (initialization; condition; increment) {}` to
repeat a block of code multiple times.
What is the output of the following code?
```javascript
let i = 0;
while (i < 3) {
console.log(i);
i++;
}
```
✔✔ The output will be `0`, `1`, `2` because the `while` loop continues as long as the condition `i
< 3` is true.
How do you create a `switch` statement in JavaScript?
✔✔ A `switch` statement is created using `switch (expression) { case value: code; break; }` to
check multiple conditions against an expression.
2
, What will the following code print?
```javascript
let x = 3;
switch (x) {
case 1:
console.log("One");
break;
case 2:
console.log("Two");
break;
case 3:
console.log("Three");
break;
default:
console.log("Default");
}
```
3