Putting the form in formatter
After a short break I found my flow a little bumping at the start of the unit- a great reminder that a daily practice is going be hugely benefical for my learning. Today we chomped our way through creating a form
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print "What's your first name?" | |
first_name = gets.chomp | |
first_name.capitalize! | |
print "What's your surname?" | |
last_name = gets.chomp | |
last_name.capitalize! | |
print "What city do you live in?" | |
city = gets.chomp | |
city.capitalize! | |
print "what state do you live in?" | |
state = gets.chomp | |
state.upcase! | |
print "#{first_name}""#{last_name}""#{city}""#{state}" |
gets take the input from the user
while chomp simple removes the extra line
The method to capitilize was forced to only be applies to the variable answer rather than the variable by simply making it exciting just add a ! to the end.
Now I wonder what a ? might do ……