Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions letsdrill.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
def get_letter_grade(integer)

#Put your code here!

case integer
when -Float::INFINITY...0
raise ArgumentError.new("score must be a positive number")
when 0..59
"F"
when 60..69
"D"
when 70..79
"C"
when 80..89
"B"
when 90..Float::INFINITY
"A"
end
end

def shortest_string(array)

#Put your code here!

unless array.nil?
array.min_by { |s| s.length }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice use of min_by!

theoretically, you could also check for if array. i'd like to call attention to two things.

  1. there's a lot of great options when working in rails - https://stackoverflow.com/questions/885414/a-concise-explanation-of-nil-v-empty-v-blank-in-ruby-on-rails
  2. there's something to keep in mind when using unless.
    http://www.railstips.org/blog/archives/2008/12/01/unless-the-abused-ruby-conditional/

end
end



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

p "Fetch Letter Grade: You should have 2 trues"
Expand Down