From 1936c046f037406b38e9fb631faf38154924d1c6 Mon Sep 17 00:00:00 2001 From: Joe Date: Wed, 5 Jul 2017 23:59:16 +0000 Subject: [PATCH 1/2] First 3 First 3 on word_count. --- app/controllers/calculations_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 0df2d0f..27b1511 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -11,11 +11,11 @@ def word_count # ================================================================================ - @word_count = "Replace this string with your answer." + @word_count = @text.split.count - @character_count_with_spaces = "Replace this string with your answer." + @character_count_with_spaces = @text.length - @character_count_without_spaces = "Replace this string with your answer." + @character_count_without_spaces = @text.gsub(/\s+/,"").length @occurrences = "Replace this string with your answer." From 78fdeb09234822b12132e4cb8102c9f9472796d3 Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 6 Jul 2017 00:07:22 +0000 Subject: [PATCH 2/2] I think I answered #4 convert @text to downcase, split, downcase @special_word and count it --- app/controllers/calculations_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 27b1511..3e28e8b 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -17,7 +17,7 @@ def word_count @character_count_without_spaces = @text.gsub(/\s+/,"").length - @occurrences = "Replace this string with your answer." + @occurrences = @text.downcase.split.count(@special_word.downcase) # ================================================================================ # Your code goes above.