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 Adding Data to Arrays

Stephen O'Connor
Stephen O'Connor
22,291 Points

helpers.js in Workspaces has different code to Dave's code in the video

I am just working through the Arrays course in Loops, Arrays and Objects and the 'helpers.js' file has a different code to Dave's code in the video, producing a console error thus meaning the code doesn't work.

helpers.js code:

function printList( list ) {
  var listHTML = '<ol>';
  for (var i = o; i < list.length; i += 1) {
    listHTML += '<li>' + elem + '</li>';
  }
  listHTML += '</ol>';
  print(listHTML);
}

function print(html) {
  document.write(html);
}

Dave's Code:

function printList( list ) {
  var listHTML = '<ol>';
  for (var i = 0; i < list.length; i += 1) {
    listHTML += '<li>' + list[i] + '</li>';
  }
  listHTML += '</ol>';
  print(listHTML);
}

function print(html) {
  document.write(html);
}

The difference being

var i = o

when it should be

var i = 0

and

listHTML += '<li>' + elem + '</li>';

when it should be

listHTML += '<li>' + list[i] + '</li>';

2 Answers

Dave McFarland
STAFF
Dave McFarland
Treehouse Teacher

Hi Stephen O'Connor

Sorry for this error, and THANK YOU for pointing it out. I've fixed the workspace so that the helper.js file has the correct code.

If you encounter any other serious errors in this course, feel free to e-mail me directly: dave@teamtreehouse.com

Stephen O'Connor
Stephen O'Connor
22,291 Points

Hi Dave,

No worries, thanks for making the changes.

Great course btw, I've been trying to pick JavaScript and jQuery up for a long time with no real success but after reading your book on the subjects and then backing that up with the Treehouse videos I now understand it and am using it a lot more in my projects.

Keep up the good work :)

Nathan Minarik
Nathan Minarik
7,358 Points

I noticed that, too. The problem still persists in the downloaded files. It's a quick easy fix, though, as noted above. Good job on the course. Enjoying it so far.

Dave McFarland
Dave McFarland
Treehouse Teacher

Thanks for point this out Nathan Minarik

I'll fix the project files too!