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 Loops, Arrays and Objects Tracking Multiple Items with Arrays Using For Loops with Arrays

Phillip Lewis
Phillip Lewis
8,549 Points

Why do the video instructions provide one set of syntax and the built in text editor use another?

When following the videos his examples use little subtle differences in coding that don't work in WorkSpace. For example: i+= vs i++ or printList vs printlist. This is confusing and waste time. I thought things were suppose to be concise, yet this is not.

I haven't seen the video myself, but the command 'i+=' is a way of using the contents of the variable (in this case 'i') then adding on the value that follows. so if 'i' has a value of 10 and the write the command 'i+=10' the new value of 'i' will be 20. where as the command 'i++' is a way to increment the value of 'i' by 1 so if 'i' still has the value of 10 then the command '!++' will give 'i' the value of 21. I don't think printList is a special javascript word, so printlist will have been created at some point in the script, you just need to make sure that you only use 'printlist' or the easier to read 'printList' throughout the script.

Hi Phillip,

Dave is using workspaces in the videos so it should be exactly the same for you in workspaces.

Do you have a specific example from a video that doesn't work the same when you do it?

Or you can post a snapshot of your workspace and tell us what isn't working.

1 Answer

David Kanwisher
David Kanwisher
9,751 Points

I'm not familiar with printList, but just remember that for the most part JavaScript will use camel-case for the names of functions. Best to use Google searches and the console log as resources. It may just be a variable name or function name that was created by the user, in that case it's important to always make sure you type it exactly that same (it's case sensitive).

i += 1 translates to i = i + 1 (an increment of 1)

i++ is an increment of 1

there is also ++i (an increment of 1)