...

/

Challenge 1: Checking Truthiness

Challenge 1: Checking Truthiness

Validate what we've learned about truthiness and print the results in a table.

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 true or false, depending on what the !!object operation, which is the same as not 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
Loginto save progress

Exercise 1: Number of Days in a Month

Challenge 2: Equivalent Objects

Loginto save progress