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 JavaScript Basics (Retired) Storing and Tracking Information with Variables The Variable Challenge

Is there a limit of how many additions you can make to a variable at a time?

I tried to add all of the variables and my own text together when creating the story variable, but it kept telling me I was missing a ";" at such and such line. So I broke the line there and did story += to add as much as I could before I saw the error again. Is there a rule for how much can be added at one time? Is it normal to have four += line for the same variable in a row?

2 Answers

Seth Kroger
Seth Kroger
56,413 Points

Four +'s in one line are fine but four +='s not so much without breaking each into their own lines/statements.

There is really no limit to the number of additions you can make to an individual variable. It's difficult to give a very specific answer without the code that's causing it but the error message from the compiler can be off by a line or two, depending on the nature of your code. Try looking at one or two lines before and after the line number in your error message.