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 trialPresley Cobb
9,214 PointsCounter as an argument instead of a concatenation.
The is the example Jim typed:
for (var counter = 10; counter; counter = counter -1){ console.log("Hello world " , counter); }
Why did he type counter as an argument instead of concatenating counter?
Is there any significant difference or is this simply two ways of writing the same code. In chrome when counter is as argument the console highlights the numbers blue. When you concatenate counter the number is black like the hello world text.
Michael Owens
5,591 PointsMichael Owens
5,591 Pointslooks like .log function has multiple forms
the first is .log(var)
the second is .log(var, var)
why did he type it the second way instead of using +, probably because it's faster