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

Passing tests #5

Open
wants to merge 2 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
52 changes: 52 additions & 0 deletions test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,58 @@
require 'pry'

class ListAnalyzer
def initialize
@vowels = ['a', 'e', 'i', 'o', 'u']
end

def number_of_words_starting_with_a_vowel list
count = 0
list.each do |word|
if word.start_with?('a', 'e', 'i', 'o', 'u')
count += 1
end
end
return count
end

def all_words_start_with_vowels? list
# one option:
#number_of_words_starting_with_a_vowel(list) == list.length
list.each do |word|
if !word.start_with?('a', 'e', 'i', 'o', 'u')
return false
end
end
return true
end

def some_word_starts_with_a_vowel? list
# one option:
#number_of_words_starting_with_a_vowel(list) > list.length
list.each do |word|
if word.start_with?('a', 'e', 'i', 'o', 'u')
return true
end
end
return false
end

def number_of_vowels_in_all_words list
number_of_vowels = 0
list.each do |word|
word.each_char do |letter|
#if letter == 'a' || letter == 'e' || letter =='i' || letter == 'o' || letter == 'u'
if @vowels.include?(letter)
number_of_vowels += 1
end
end
end
return number_of_vowels
end




end


Expand Down