Created
March 7, 2014 04:01
-
-
Save bootcoder/9405030 to your computer and use it in GitHub Desktop.
get_grade inject
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_grade(array) | |
average = array.inject(:+).to_f / array.length | |
case average | |
when 0..59 | |
"F" | |
when 60..69 | |
"D" | |
when 70..79 | |
"C" | |
when 80..89 | |
"B" | |
when 90..100 | |
"A" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment