learn-co-curriculum / collections_practice_vol_2

More practice with iteration and nested data structures
Other
0 stars 5 forks source link

Wrong solution for #first_wa #11

Closed lukegrecki closed 5 years ago

lukegrecki commented 8 years ago

The solution given also returns words with a "wa" anywhere in the string. Here's my solution:

def first_wa(array)
  array.find { |word| word[0..1] == "wa"}
end

This solution only matches "wa" at the start of the string.

HuydDo commented 5 years ago

def first_wa(array) wa_arr = [] array.each do |item| if item[0..1] == ("wa") wa_arr << item end end

wa_arr[0]

wa_arr.first

end

maxwellbenton commented 5 years ago

Hi @lukegrecki,

Thank you for spotting this and opening an issue. We've updated this lesson and incorporated changes based on you feedback, updating the tests and solution so that they align with the test message. The previous solution will no longer work, but your example solution still will.

Thank you for contributing to a Learn lesson!