Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to assign the boolean value true to the variable.
Ruby
is_valid = [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using capitalized True instead of true
Using false or nil instead of true
✗ Incorrect
In Ruby, the boolean value for true is true (all lowercase).
2fill in blank
mediumComplete the code to assign the boolean value false to the variable.
Ruby
is_active = [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using capitalized False instead of false
Using true or nil instead of false
✗ Incorrect
In Ruby, the boolean value for false is false (all lowercase).
3fill in blank
hardFix the error in the code by replacing the incorrect nil value.
Ruby
result = [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing nil with false
Using capitalized True or true incorrectly
✗ Incorrect
Here, false is the correct boolean value to use instead of nil if you want a boolean false.
4fill in blank
hardFill both blanks to create a condition that checks if a variable is nil or false.
Ruby
if value == [1] || value == [2] puts "Value is false or nil" end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'None' instead of nil
Using true instead of false
✗ Incorrect
To check if a variable is either nil or false, use both values in the condition.
5fill in blank
hardFill all three blanks to create a hash that maps keys to boolean or nil values.
Ruby
status = { success: [1], error: [2], pending: [3] } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using capitalized True or False
Using strings instead of boolean values
Confusing nil with false
✗ Incorrect
This hash uses Ruby boolean values true, false, and nil correctly.