Beginners Ruby question


#1

Instructions:

Inside your when "add" block, remove the puts "Added!" statement.
In its place, prompt the user for a movie title. Save the result in a new variable called title. (*Your code already has an example of how to do this!)
Next, prompt the user for the rating of the movie. Save that in a new variable called rating.
Add that movie/rating pair to the movies hash and puts a message indicating the pair was added. (No need for to_sym or to_i just yet!)

what I've done so far:

movies = {
'Batman' => 'SpiderMan'
}
puts "Do you like coding in Ruby?"
choice = gets.chomp

movies = {
SilverStrand: 5,
}

puts "Please enter your favorite movie!"

choice = gets.chomp

case choice

when 'add'

puts " What is the title of your favorite movie?"
title = gets.chomp

puts "Give me a rating of the movie of 1-10"
rating = gets.chomp

when 'update' 
puts "Updated!"

when 'display' 
puts "Movies!"

when 'delete' 
puts "Deleted!"

else
puts "Error!"
end

i don't know what to do after this, can someone help me please? Thank you


#2

Hi you've done the first part of the instruction but it's missing this part
Add that movie/rating pair to the movies hash and puts a message indicating the pair was added. (No need for to_sym or to_i just yet!)


#3

Thank you for answering and i put this and i am still getting an error:

movies=[title, rating]
puts "Movie and rating successfully added!"
when "update"
puts "Updated!"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end


#4

It should be like that

movies[title] = rating

#6

sorry my mistake! it still doesn't work. Can you take a look at my code and see what i am doing wrong?

movies = {
'Batman' => 'SpiderMan'
}
puts "Do you like this movie?"
choice = gets.chomp

movies = {
SilverStrand: 5,
}

puts "Please enter your favorite movie!"

choice = gets.chomp

case choice

when 'add'

puts "please enter the title of this movie"
title = gets.chomp

puts" please enter a rating 1-10"
rating = gets.chomp
movies[title] = rating
puts "Movie and rating successfully added!"

when 'update' 
puts "Updated!"

when 'display' 
puts "Movies!"

when 'delete' 
puts "Deleted!"

else
puts "Error!"
end


#7

first remove thes line

puts "Do you like this movie?"
choice = gets.chomp

Then when you Save & Submit Code you should put add and the name of movie then the rating