Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List Challenge #9

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 46 additions & 1 deletion test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,52 @@
require 'pry'

class ListAnalyzer
end

def starts_with_vowel word
word.start_with?("a", "e", "i", "o", "u")
end

def number_of_words_starting_with_a_vowel words
words_starting_with_vowel = 0
words.each do |word|
if starts_with_vowel word
words_starting_with_vowel += 1
end
end
words_starting_with_vowel
end

def all_words_start_with_vowels? words
words.each do |word|
unless starts_with_vowel word
false
end
end
end

def number_of_vowels_in_all_words words
number_of_vowels = 0
words.each do |word|
letters = word.split("")
letters.each do |letter|
if starts_with_vowel letter
number_of_vowels += 1
end
end
end
number_of_vowels
end

def some_word_starts_with_a_vowel? words
words.each do |word|
if starts_with_vowel word
return true
end
end
return false
end

end

class ListTest < MiniTest::Test
def test_it_can_count_vowels
Expand All @@ -18,6 +62,7 @@ def test_it_can_check_a_whole_list_for_matches
mostly_vowels = ["iceberg", "ugli", "endive", "plum", "olive"]

lister = ListAnalyzer.new
binding.pry
refute lister.all_words_start_with_vowels?(mostly_vowels)

mostly_vowels.delete "plum"
Expand Down