From bfad89710114d4995a1a45f1f1b87c88241d8371 Mon Sep 17 00:00:00 2001 From: AlexRichards9595 Date: Mon, 2 Jul 2018 16:27:52 -0400 Subject: [PATCH 1/3] Finished capitalize each string --- challenge.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/challenge.rb b/challenge.rb index 0585882..e4ab9b7 100644 --- a/challenge.rb +++ b/challenge.rb @@ -1,6 +1,6 @@ def capitalize_each_string(input) - #implement your solution here + input.map{ |x| x.capitalize} end def fetch_the_dog(input) @@ -29,7 +29,7 @@ def fetch_CD_animals(input) p capitalize_each_string(animals) == ["Cat", "Moose", "Dog", "Bird"] -p fetch_the_dog(animals) == ["dog"] +p fetch_the_dog(animals) == ["dog"] p no_dogs_allowed(animals) == ["cat", "moose", "bird"] From 6a731f54e133caa351eb0d20bf1c9f4f4ea478cc Mon Sep 17 00:00:00 2001 From: AlexRichards9595 Date: Tue, 3 Jul 2018 10:29:56 -0400 Subject: [PATCH 2/3] Finished all of them. --- challenge.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/challenge.rb b/challenge.rb index e4ab9b7..731651f 100644 --- a/challenge.rb +++ b/challenge.rb @@ -4,23 +4,22 @@ def capitalize_each_string(input) end def fetch_the_dog(input) - #implement your solution here + input.reject { |e| e != "dog" } end def no_dogs_allowed(input) - #implement your solution here -end + input.reject { |e| e == "dog" }end def count_the_animals(input) - #implement your solution here + input.size end def fetch_the_first_two(input) - #implement your solution here + input[0,2] end def fetch_CD_animals(input) - #implement your solution here +input.select { |e| e[/\b[cd]/]} end ## DO NOT CHANGE CODE BELOW THIS LINE ## From 4d037b2c645a8be9ddfdb3cb15c12106de64d65e Mon Sep 17 00:00:00 2001 From: AlexRichards9595 Date: Tue, 3 Jul 2018 12:02:25 -0400 Subject: [PATCH 3/3] I like the .first method. And I would have much rather used the select method, but the instructions say that we can only use each method once. But now I realized I used the reject method twice anyways so it doesn't matter --- challenge.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenge.rb b/challenge.rb index 731651f..e1ad9f0 100644 --- a/challenge.rb +++ b/challenge.rb @@ -15,7 +15,7 @@ def count_the_animals(input) end def fetch_the_first_two(input) - input[0,2] + input.first(2) end def fetch_CD_animals(input)