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

JavaScript Introducing the Practice

Concatenation

I realize we learned concatenation but I am having trouble seeing how it worked in the first for loop example. He created a variable called "text," then ran the loop and out came "1 2 3 4". I feel like that part was glossed over a bit. Someone, please explain that, because that has been what has been stumping me more than the actual loops.

I actually got the answer off a freecodecamp forum. I found that the empty variable is expected to be a string.

1 Answer

Steven Parker
Steven Parker
231,248 Points

You can think of concatenation as "glue", so it just sticks two strings together to make one longer one.

When the first string is empty, concatenating it does the same thing as assigning it with the second value.