From 1b59f69b2af266b3d948f16a6aad01be7253b77e Mon Sep 17 00:00:00 2001 From: = <=> Date: Fri, 22 May 2020 11:43:13 -0400 Subject: [PATCH 1/5] Add my solution to both problems --- letsdrill.rb | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/letsdrill.rb b/letsdrill.rb index 9371cf5..45dca80 100644 --- a/letsdrill.rb +++ b/letsdrill.rb @@ -1,13 +1,34 @@ def get_letter_grade(integer) - #Put your code here! + if integer >= 90 then + return "A" + elsif integer >= 80 then + return "B" + elsif integer >= 70 then + return "C" + elsif integer >= 60 then + return "D" + end + + return "F" end def shortest_string(array) - #Put your code here! + if array.length == 0 + return nil + end + + shortest = array[0] + + array.each { |item| + if item.length < shortest.length then + shortest = item + end + } + return shortest end From f52d1315e97480a03f1aaf47b37a8bf6fded8bd4 Mon Sep 17 00:00:00 2001 From: = <=> Date: Wed, 27 May 2020 12:37:20 -0400 Subject: [PATCH 2/5] Change double quotes to single quotes since I'm not interpolating --- letsdrill.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/letsdrill.rb b/letsdrill.rb index 45dca80..fac510f 100644 --- a/letsdrill.rb +++ b/letsdrill.rb @@ -1,16 +1,16 @@ def get_letter_grade(integer) if integer >= 90 then - return "A" + return 'A' elsif integer >= 80 then - return "B" + return 'B' elsif integer >= 70 then - return "C" + return 'C' elsif integer >= 60 then - return "D" + return 'D' end - return "F" + return 'F' end From 2dada08e6a6039905a2ab00ec43bccc6ebacd2e1 Mon Sep 17 00:00:00 2001 From: = <=> Date: Wed, 27 May 2020 12:38:58 -0400 Subject: [PATCH 3/5] Remove explicit return values --- letsdrill.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/letsdrill.rb b/letsdrill.rb index fac510f..af39fe7 100644 --- a/letsdrill.rb +++ b/letsdrill.rb @@ -1,17 +1,17 @@ def get_letter_grade(integer) if integer >= 90 then - return 'A' + 'A' elsif integer >= 80 then - return 'B' + 'B' elsif integer >= 70 then - return 'C' + 'C' elsif integer >= 60 then - return 'D' + 'D' + else + 'F' end - return 'F' - end def shortest_string(array) From 0f9bc60a2eacd520e41ed77ff2580a0ccf28fa9f Mon Sep 17 00:00:00 2001 From: = <=> Date: Wed, 27 May 2020 12:39:47 -0400 Subject: [PATCH 4/5] Remove unnessecary then --- letsdrill.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/letsdrill.rb b/letsdrill.rb index af39fe7..967da78 100644 --- a/letsdrill.rb +++ b/letsdrill.rb @@ -23,7 +23,7 @@ def shortest_string(array) shortest = array[0] array.each { |item| - if item.length < shortest.length then + if item.length < shortest.length shortest = item end } From 3d8d70193bf0213cd4c5183d0f3e0690ecf838fe Mon Sep 17 00:00:00 2001 From: = <=> Date: Wed, 27 May 2020 12:55:52 -0400 Subject: [PATCH 5/5] Swap curly braces for do/end --- letsdrill.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/letsdrill.rb b/letsdrill.rb index 967da78..1b8eaff 100644 --- a/letsdrill.rb +++ b/letsdrill.rb @@ -22,11 +22,11 @@ def shortest_string(array) shortest = array[0] - array.each { |item| + array.each do |item| if item.length < shortest.length shortest = item end - } + end return shortest end