3 - The Case Statement


#1

https://www.codecademy.com/courses/learn-ruby/lessons/a-night-at-the-movies/exercises/the-case-statement?action=lesson_resume&link_content_target=interstitial_undefined

Below is my code. It’s running and returning ‘Movies!’, regardless of what the user types in.

```

movies = {
  'Truman Show' => '8/10'
  }

puts "What would you like to do?"
answer = gets.chomp

# puts "The user said they wanted to #{answer}"
case choice
  when "add"
  	puts "Added!"
  when "update"
  	puts "Updated!"
  when "display"
  	puts "Movies!"
  when "delete"
  	puts "Deleted!"
	else
  	puts "Error!"
end

#2

Turns out I was missing a bit of code from the last step, the choice = gets.chomp


#3

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