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

Monday, January 14, 2013

Codecademy Sample Solution: Error! Error!



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
if movies[title.to_sym] === nil
puts "Enter the movie's rating:"
rating = gets.chomp
movies[title.to_sym] = rating.to_i
#test
puts movies
puts "Movie title and rating has been added!"
else
puts movies
puts "Movie already exists!"
end
when 'update'
puts "Updated!"
when 'display'
puts "Movies!"
when 'delete'
puts "Deleted!"
else
puts "Error!"
end

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts