Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
kennethortiz
5,825 PointsQuestionnaire Review
I just finished the Ruby Basics course, which was awesome, I might add! At the end of Methods review, Jason said to try and come up with a questionnaire or movie review for practice.
Can someone review my code and let me know if my code is looks good and/or if there was a better way to code it.
puts "What is your name?"
name = gets
puts "How old are you?"
age = gets
puts "What is your favorite movie?"
favorite_movie = gets
bio = <<-BIO
Here's what I know about you so far:
Your name is #{name}.
You are #{age} years old.
You're favorite movie is #{favorite_movie}.
BIO
puts bio
Also, the output looked a little funky to me. For some reason, some words were returned on another line instead of the same line as the sentence, see below:
treehouse:~/workspace$ ruby practice.rb
What is your name?
Ken
How old are you?
32
What is your favorite movie?
LOTR
Here's what I know about you so far:
Your name is Ken
.
You are 32
years old.
You're favorite movie is LOTR
.
1 Answer
Kevin Marshall
3,561 PointsYou want to use gets.chomp. It removes the new line character from you code. Looks good though!
kennethortiz
5,825 Pointskennethortiz
5,825 PointsThanks for the quick response Kevin!
I tried gets.chomp and it fixed the new line issue I had :)