0
0
Typescriptprogramming~10 mins

Boolean type behavior in Typescript - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a boolean variable with value true.

Typescript
let isActive: boolean = [1];
Drag options to blanks, or click blank then click option'
A"true"
Byes
C1
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around true, making it a string instead of a boolean.
Assigning numbers like 1 or 0 instead of true or false.
2fill in blank
medium

Complete the code to check if the variable is false.

Typescript
if ([1] === false) {
  console.log("It is false");
}
Drag options to blanks, or click blank then click option'
AisActive === false
B!isActive
CisActive == true
DisActive
Attempts:
3 left
💡 Hint
Common Mistakes
Writing the comparison twice like isActive === false === false.
Using negation !isActive when the code already compares to false.
3fill in blank
hard

Fix the error in the code to assign a boolean value correctly.

Typescript
let isDone: boolean = [1];
Drag options to blanks, or click blank then click option'
Afalse
B"false"
C0
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning the string "false" instead of the boolean false.
Using numbers like 0 or null which are not boolean values.
4fill in blank
hard

Fill both blanks to create a boolean expression that checks if x is true and y is false.

Typescript
if (x [1] true && y [2] false) {
  console.log("Condition met");
}
Drag options to blanks, or click blank then click option'
A===
B==
C!=
D!==
Attempts:
3 left
💡 Hint
Common Mistakes
Using loose equality == which can cause unexpected results.
Using inequality operators which check for difference, not equality.
5fill in blank
hard

Fill all three blanks to create a boolean expression that checks if a is true and c is true.

Typescript
if ([1] [2] true && [3] === true) {
  console.log("All conditions met");
}
Drag options to blanks, or click blank then click option'
Aa
Bb
C===
Dc
Attempts:
3 left
💡 Hint
Common Mistakes
Using loose equality == instead of strict equality ===.
Mixing variable names or operators in wrong blanks.