Created
March 19, 2015 02:40
-
-
Save ddzager/7e265eb615fd28eb61c7 to your computer and use it in GitHub Desktop.
hw not uploaded properly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dirty_words = ['pee', 'poop', 'she-dog', 'phallus', 'fornicate', 'frack'] | |
#prompt user to say bad words | |
puts "Go ahead, say your worst:" | |
#accept an input sentence, making sure to make input_phrase lower case | |
input_phrase = gets.chomp.downcase | |
#creat an array of words from input_sentence | |
user_words = input_phrase.split() | |
#is there an intersection between the two arrays? | |
a = user_words & dirty_words | |
#a will return the dirty words that match, but will return nil if no intersection | |
#this is where I get caught up....if the intersection is not nil that means there are dirty words | |
if a != [] | |
puts "We're rejecting that, you potty mouth" | |
else | |
puts "Okay, we'll publish that." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment