diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 39a7688..5c049f5 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -15,6 +15,7 @@ //= require bootstrap //= require turbolinks //= require_tree . +//= require jquery //= require moment //= require bootstrap-datetimepicker diff --git a/app/controllers/calculations_controller.rb b/app/controllers/calculations_controller.rb index 0df2d0f..f143fcc 100644 --- a/app/controllers/calculations_controller.rb +++ b/app/controllers/calculations_controller.rb @@ -11,13 +11,13 @@ 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.size - @character_count_without_spaces = "Replace this string with your answer." + @character_count_without_spaces = @text.gsub(" ","").size - @occurrences = "Replace this string with your answer." + @occurrences = @text.downcase.gsub(/[^a-z0-9\s]/i,"").split.count(@special_word.downcase) # ================================================================================ # Your code goes above. @@ -38,7 +38,8 @@ def loan_payment # The principal value the user input is in the decimal @principal. # ================================================================================ - @monthly_payment = "Replace this string with your answer." + @apr_decimal = @apr/1200 + @monthly_payment = (@apr_decimal/(1-(1+@apr_decimal)**(-1*@years*12)))*@principal # ================================================================================ # Your code goes above. @@ -60,12 +61,12 @@ def time_between # number of seconds as a result. # ================================================================================ - @seconds = "Replace this string with your answer." - @minutes = "Replace this string with your answer." - @hours = "Replace this string with your answer." - @days = "Replace this string with your answer." - @weeks = "Replace this string with your answer." - @years = "Replace this string with your answer." + @seconds = @ending-@starting + @minutes = @seconds/60 + @hours = @minutes/60 + @days = @hours/24 + @weeks = @days/7 + @years = @weeks/52 #hopefully this is done # ================================================================================ # Your code goes above.