4. Prompting: Redux! help


#1

I've checked over my code, yet the same error message persists:

"Oops Try again. Did you create a variable called title?"

and

Syntax error, unexpected keyword_when, expecting $end when "update"

Here's my code:

movies = {
Pulp_Fiction: 4
}

puts "What would you like to do?"

choice = gets.chomp

case choice
when 'add'
puts "What movie do you want to add?"
title = gets.chomp
puts "What's the rating? (add a number 0 to 4.)"
rating = gets.chomp
movies[title] = rating
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

Any ideas as to what I did wrong, as I can't seem to figure it out?


#2

Nevermind, I guess it was a bug. I refreshed the page, and retyped the code and then it worked. Would be nice if this site wouldn't tell you that you've done something wrong when you haven't.
lol


#3

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


#4

I tried nutilus's code and it didn't work. Can someone help me


#5

nevermind. I did it myself