Quotes help make search much faster. Example: "Practice Makes Perfect"

Monday, January 14, 2013

Codecademy Sample Solution: Prompting: Redux!



movies = {
tron: 4,
jaws: 3,
inception: 5
}

puts "Enter a choice ('add', 'update', 'display', 'delete'):"
choice = gets.chomp.downcase
#puts choice
case choice
when 'add'
puts "Enter the movie title you'ld like to add:"
title = gets.chomp
puts "Enter the movie's rating:"
rating = gets.chomp
movies[title] = rating
#test
puts movies
puts "Movie title and rating has been added!"
when 'update'
puts "Updated!"
when 'display'
puts "Movies!"
when 'delete'
puts "Deleted!"
else
puts "Error!"
end

1 comment:

  1. Thank you, the "movies[title] = rating" really saved me :)

    ReplyDelete


This is an example of scrolling text using Javascript.

Popular Posts