Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Introduction to Programming Control Structures Loops

Presley Cobb
Presley Cobb
9,214 Points

Counter 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
Michael Owens
5,591 Points

looks 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