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 trialnathaniel marquez
Full Stack JavaScript Techdegree Student 2,145 PointsFrustrated.
Im not even sure how to ask this ...
concatenation does not require a space while space does make strings and the like more readable its not required. So ...
I chose the answer with
'hello' + 'world' <--- was told this is wrong because it needs a space.
Fine ...
I chose the answer ... NONE of the above cause NONE of them have a space to the right of any of the strings. <--- was told I was wrong still ...
also ... while i was typing this message out I was apparently taking the test too, because the background kept selecting answers and typing while I was typing this message ... and amazingly I got it wrong still.
:( Frustrated.
1
2 Answers
jason chan
31,009 Points'hello' + ' world'
// be very careful of spaces
brandonlind2
7,823 PointsThe space in a string " inside" is needed, because the space is treated like another character i think, so for example if you need to create a sentance you would need spaces,
var sent= 'this is a sentence';// this is a sentence
var sent2="thisisasentnece";//thisisasentence
var sent3="this is a" + "sentence";//this is asentence"
//spaces are required for strings
//but its not required for concatenation
//which means a space isn't required out side the string
//outside not required " inside required" outside not required + " inside required"
//for exmple
var string1= "this " + "is " + "a " + "string ";
//is the same as
var string2= "this "+"is "+"a "+"string";
//note it works the same and a space isnt required when concatenating, in other words a space isnt required with the + sign
// but its required inside a string
nathaniel marquez
Full Stack JavaScript Techdegree Student 2,145 Pointsinteresting ... I was going to a tech college and I was told or advised rather that when concatenating was done the space should read from left to right ...
so it would go like ... "is required " <--- space here + "is required" <--- space not here. and doing it as tree house suggested was wrong.
I guess it was a personal preference the instructor had at the tech college.
Ethan M
10,637 PointsEthan M
10,637 PointsYes, otherwise the response will be helloworld