Skip to content

Latest commit

 

History

History
30 lines (26 loc) · 987 Bytes

fix_your_code_before_the_garden_dies.md

File metadata and controls

30 lines (26 loc) · 987 Bytes

Description

You have an award-winning garden and every day the plants need exactly 40mm of water. You created a great piece of JavaScript to calculate the amount of water your plants will need when you have taken into consideration the amount of rain water that is forecast for the day. Your jealous neighbour hacked your computer and filled your code with bugs.

Your task is to debug the code before your plants die!

def rain_amount(mm) do
    if (rain_amount = 40) then
         return "You need to give your plant " + {rain_amount - 40} + " mm of water"
    end
    if else then
         return "Your plant has had more than enough water for today!"
    end
end

My Solution

def rain_amount(mm)
  if mm < 40
    "You need to give your plant " + "#{40 - mm}" + "mm of water"
  else 
    "Your plant has had more than enough water for today!"
  end
end