Skip to content

Commit

Permalink
updated guard and enum method
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewlee07 committed Sep 28, 2018
1 parent e227a9e commit 2638340
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions letsdrill.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
def get_letter_grade(integer)

return "Invalid Input" unless /\A\d+\z/ =~ integer.to_s

case integer
when 91..100
"A"
Expand All @@ -10,20 +13,19 @@ def get_letter_grade(integer)
"D"
when integer<60
"F"
else
"Invalid Input"
end
end

def shortest_string(array)
array.sort_by {|string| string.length}[0]
array.min_by {|string| string.length}

This comment has been minimized.

Copy link
@sjreich

sjreich Sep 29, 2018

👍

end



### Don't touch anything below this line ###

p "Fetch Letter Grade: You should have 2 trues"
p "Fetch Letter Grade: You should have 3 trues"
p get_letter_grade("Not an integer") == "Invalid Input"
p get_letter_grade(89) == "B"
p get_letter_grade(73) == "C"
p
Expand Down

0 comments on commit 2638340

Please sign in to comment.