Please help me


#1


<Below this line, add a link to the EXACT exercise that you are stuck
can anyone explain to me what is wrong with this code?

puts "what is your favorite genre of movies?"
user_input=gets.chomp.capitalize

if user_input=["Horror","Action"]
puts "Nice taste"
elsif user_input=["Romance","Chick Flick"]
puts "thats horrible"
else
puts "ehh there alright i guess"
end


Replace this line with your code.


#2

user_input will be a string, not an array. Recall, also, that we need to compare, ==.

http://ruby-for-beginners.rubymonstas.org/operators/comparison.html


To continue,

puts " ... "              # display a prompt
user_input = gets.chomp   # get string and remove trailing white space

if user_input == "Horror" || user_input == "Action"    # || => or
    # code
# ...
end

And furthermore,

Ruby does have an include? method for looking inside an array...

if ["Horror", "Action"].include? (user_input)
    # code
end

but this might be jumping ahead of the lesson.

Lastly, please post a link to the exercise. Thanks.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.