Created
June 4, 2016 19:00
-
-
Save dsomel21/ac9ab55c1e77490f5e25a2829b10ee76 to your computer and use it in GitHub Desktop.
Return the highest value of an array
This file contains 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 maximum(arr) | |
highest = arr[0] | |
arr.each {|num| return highest = num if num>highest} | |
return highest | |
end | |
puts maximum([19, 69, 21, 55]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment