Super noob. Could someone tell me my error

I am using a coding book combined with youtube and code academy to learn
ruby and I am stuck here. I am trying to create a full name website
greeting.
Here is my code

Puts ‘Welcome to my crappy website, and what’s your first name?’
firstname=gets.chomp
puts ‘Awesome!, whats your middle name?’
middlename = gets.chomp
puts ‘Lastly, last name!’
lastname = gets.chomp
puts 'Your name is ’ + firstname+middlename+lastname+ ‘? What an ugly
name!’
uy

How are you running the code?
Have you tried reading the error message?

This may be a case of the blind trying to lead the blind but here goes.

In line 7 and 8 of your code, try changing single quotes to double
quotes. Ruby does not interpret the content between single quotes, but
treats it as a string literal. If you want to make insertions, such as
concatenation and value substitutions instead of variable names, use
double quotes.

puts ‘firstname+middlename+lastname’ #=> firstname+middlename+lastname

#The following code will display the value of the variables instead of
the variable names.

puts “Your name is #{firstname} #{middlename} #{lastname}”

#Also, what is the “uy” at the end? Is that part of your code? If so,
what is it for?

Great thanks for the help! its helped me out. The UY was just a mistake.
I got the code to work. I tried using double quotes and it worked. Also
it turned out that in line 1 the P in puts should have been lower case.

I think I misread your code. If the user entered Robert as the first
name, Bartholomew as the middle name and Albertson as the last name,
your code should yield:

Your name is RobertBartholomewAlbertson? What an ugly name!

You should get the result you want if you use my code or change your
code to:

puts 'Your name is ’ + firstname + ’ ’ + middlename + ’ ’ + lastname +
‘? What an ugly name!’

If you still have problems after trying the two alternatives, specify
the error message and the related code.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs