Challenge 1: Checking Truthiness
Validate what we've learned about truthiness and print the results in a table.
We'll cover the following...
We'll cover the following...
Problem statement
This exercise is about validating what we’ve learned about truthiness, and printing the results in a tabular form.
Consider the following array:
objects = [true, false, nil, 0, 1, "", []]
Add some code so that it outputs the following table:
object | !!object
true | [true|false]
false | [true|false]
nil | [true|false]
0 | [true|false]
1 | [true|false]
"" | [true|false]
[] | [true|false]
Note: The last column should be filled in with either
trueorfalse, depending on what the!!objectoperation, which is the same asnot not object, returns for each of the objects.
Try it yourself
puts "object\t| !!object"objects = [true, false, nil, 0, 1, "", []]# Start your code here