diff --git a/lib/array_equals.rb b/lib/array_equals.rb index 58e8369..d598a5c 100644 --- a/lib/array_equals.rb +++ b/lib/array_equals.rb @@ -1,5 +1,22 @@ -# Determines if the two input arrays have the same count of elements -# and the same integer values in the same exact order def array_equals(array1, array2) - raise NotImplementedError + if array1 != nil && array2 != nil + + if array1.count == array2.count + index = array1.count + (0..index).each do |i| + if array1[i] == array2[i] + return true + else + return false + end + end + else + return false + end + + elsif array1 == nil && array2 == nil + return true + else + return false + end end diff --git a/test/array_equals_test.rb b/test/array_equals_test.rb index f745cf7..2002fde 100644 --- a/test/array_equals_test.rb +++ b/test/array_equals_test.rb @@ -2,6 +2,8 @@ require 'minitest/reporters' require_relative '../lib/array_equals' +Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new + describe "array equals" do describe "basic tests" do it "arrays are equal" do