Skip to content

Latest commit

 

History

History
33 lines (28 loc) · 806 Bytes

grasshopper_if_else_syntax_debug.md

File metadata and controls

33 lines (28 loc) · 806 Bytes

Description

If/else syntax debug

While making a game, your partner, Greg, decided to create a function to check if the user is still alive called checkAlive/CheckAlive/check_alive. Unfortunately, Greg made some errors while creating the function.

checkAlive/CheckAlive/check_alive should return true if the player's health is greater than 0 or false if it is 0 or below.

The function receives one parameter health which will always be a whole number between -10 and 10.

def check_alive(health)
  if ()
    health < 0
    return False
  else
    return True
  end
end

My Solution

def check_alive(health)
  if health <= 0
    false
  else
    true
  end
end