What am i doing wrong it won't pass


#1

case choice
when "add"
puts "What movie do you want to add? "
title = gets.chomp
puts "What's the rating?"
rating = gets.chomp
movies[title] = rating
puts "#{title} has been added with a rating of #{rating}."
end

please help


#2

Is that your whole code?


#3

movies = {
'bompton' => 7 ,
'coming' => 10,
}
puts "Do you like bompton?"
choice = gets.chomp

case choice
when "add"
puts "What movie do you want to add? "
title = gets.chomp
puts "What's the rating?"
rating = gets.chomp
movies[title] = rating
puts "#{title} has been added with a rating of #{rating}."
end
when "updated"
puts "Updated!"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end


#4

@arjofocolovi this is my whole my code ^^^^


#5
puts "#{title} has been added with a rating of #{rating}."
end

If you use end here, you're closing your case, which is not what you want (since you have several other cases after this one).


#6

yea but when i changed it it says "It looks like you didn't add to the movies hash!"


#7

@arjofocolovi^^^ ^^^^^^^^


#8

Without the end, your code passes the exercise on my side. Try reloading the page and deleting the cache of your browser.


#9

movies = {
'bompton' => 3,
'hero' => 4,
}
puts "What's your favorite movie?"
choice = gets.chomp
case choice
when "add"
puts "What movie do you want to add?"
title = gets.chomp
puts "What's the rating?"
rating = gets.chomp
movies[title] = rating
puts "#{title} has been added with a rating of #{rating}."
when "updated"
puts "Updated!"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end


#10

@arjofocolovi it still doesn't work and says i haven't added it to my hash


#11

I'm having the same problem. Here's my code.

movies={}
puts "What's your favorite movie?"
puts "Do you want to add, update, display, or delete?"
choice=gets.chomp
case choice
when "add"
puts "Movie title please"
title=gets.chomp.intern
puts "Movie rating please (0-4)"
rating=gets.chomp.to_i
if movies[title.to_sym]=nil

when "update"
    puts "Updated!"
when "display"
    puts "Movies!"
when "delete"
    puts "Deleted!"

else
puts "Error!"
end
movies[title.intern]=rating.to_i
movies="#{title}=>#{rating}"

To be clear I have no idea what I'm doing.


#12

GOT IT!!!! Hallelujah that took like an hour. This works.

movies={}
puts "What's your favorite movie?"
puts "Do you want to add, update, display, or delete?"
choice=gets.chomp
case choice
when "add"
puts "Movie title please"
title=gets.chomp.intern
puts "Movie rating please (0-4)"
rating=gets.chomp.to_i
movies[title] = rating
if movies[title.to_sym].nil?
puts "#{title} has been added with a rating of #{rating}."
end
when "update"
puts "Updated!"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end
movies[title.intern]=rating.to_i
movies="#{title}=>#{rating}"