Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add my solution to both problems #121

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
25 changes: 23 additions & 2 deletions letsdrill.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
def get_letter_grade(integer)

#Put your code here!
if integer >= 90 then

Choose a reason for hiding this comment

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

Awesome work! There are some styling things going on here so I wanted to link the style guide for reference: https://github.com/rubocop-hq/ruby-style-guide

Using ' single tick quotes when you aren't interpolating.
Don't need to explicitlty call return to return values, ruby will evaluate the last line of the method as is and return it.

Functionality wise here this work but does it seem like it's starting to get a little lengthy? If you have a hunch you are correct, check out case statements and also you can have the final catch in your if/elsif/else be an else instead of the return outside of the if statement

'A'
elsif integer >= 80 then
'B'
elsif integer >= 70 then
'C'
elsif integer >= 60 then
'D'
else
'F'
end

end

def shortest_string(array)

#Put your code here!
if array.length == 0
return nil
end

shortest = array[0]

array.each do |item|
if item.length < shortest.length
shortest = item
end
end

return shortest
end


Expand Down