Truthiness Code Challenge

Objectives

  1. Strengthen your understanding of truthiness in Ruby
  2. Practice using boolean and comparison operators

Code Challenge

Take a look at the code below. We have defined a method, returning_true that uses a comparison operator, the < (less than) to compare the number 14 to... nothing. What value(s) for ? will make returning_true return true?

def returning_true
  14 < ?
end

1
15
14
17

Here we have a method, returning_false that uses both comparison and boolean operators. What value(s) for ? will make returning_false return false?

def returning_false
  7 > 4 && 100 < ?
end

100
101
102
103

Take a look at the method using_truthiness below. What value(s) for ? will make using_truthiness return false?

def using_truthiness
  7 > 8 || ?
end

false
8 > 9
!true
!false

What value(s) for ? will make using_truthiness return true?

def using_truthiness
  7 > 8 || ?
end

7 > 6
7
false
8 > 9

View Truthiness Code Challenge on Learn.co and start learning to code for free.

Unlock your future in tech
Learn to code.

Learn about Flatiron School's Mission

With a new take on education that falls somewhere between self-taught prodigy and four-year computer science degree, the Flatiron School promises to turn students with little programming experience into developers.

In the six months since the Manhattan coding school was acquired by WeWork, it has spawned locations in Washington, D.C., Brooklyn, and London. Now, WeWork is opening a fourth Flatiron School location, this time in Houston.

Adam Enbar, Flatiron School's cofounder, believes now is the time to grow. "How the world is changing has impacted working and learning in very similar ways. We think education fundamentally is about one thing: enabling people to pursue a better life."

Learn. Love. Code.
Students come to Flatiron School to change their lives. Join our driven community of career-changers and master the skills you need to become a software engineer or a data scientist.
Find Us