How can I make just the first letter of user input capitalized, so that if they enter the same movie title as one given, but all in lowercase, they can still receive the error message that the title already exists?


#1



https://www.codecademy.com/courses/ruby-beginner-en-0i8v1/0/7?curriculum_id=5059f8619189a5000201fbcb

N/A


movies = {
    Movie: 1,
    Moviee: 2,
    Movieee: 3,
    Movieeee: 4}
    puts "What we gonna do?" 
    choice=gets.chomp
    case choice
    when "add"
    puts "Added!"
    when "update"
    puts "title?"
    title=gets.chomp(/./, &:upcase)
    if movies[title.to_sym]
        puts "rating"
    rating = gets.chomp.sub
    movies[title.to_sym]=rating.to_i
        puts "Title has been updated!"
    else
        puts "That Doesn't Exist!"
    end
    when "display"
    puts "movies!"
    when "delete"
    puts "delete"

end

I have it set up this way, why is this not working? I


#2

See if there aren't any string methods for that, you can call the method methods to find out what is available or you can look it up in documentation or google for it.

irb(main):001:0> puts 'hello'.methods.sort

#3

Just do title = gets.chomp.capitalize or whatever = blah.blah.capitalize to capitalize something.


#4

WOW. Rookie mistake sorry! Thank you!


#5

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