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

Creating playlist.js

Hi everyone, maybe this is a stupid question! But why Dave created the playlist.js file outside the folder js? Do I always have to create a second js file, like in this case, outside the main folder? Thanks!

3 Answers

Steven Parker
Steven Parker
230,248 Points

If you want, you can put all your JavaScript into one file. But for manageability on large projects, and for functional separation on any size project, it can often be useful to have your code in multiple files.

Thanks Steven for the reply, but my question was different. I'd simply like to know why he created playlist.js outside the folder js and after he put again playlist.js in the folder js... Couldn't he immediately create the folder playlist.js directly in the folder js?? Is there a reason why he did it so or not?

I would like to know that too, I created mine directly in the js file and now my array won't print.

Maximiliane Quel
PLUS
Maximiliane Quel
Courses Plus Student 55,489 Points

He created it outside of the folder by mistake, because he was not on the js folder when he chose File > New File. So he simply moved it into the folder afterwards. So yes, he could have created the file straight in the folder.

@melissakeith If the array is not printing there is something else wrong with your code or setup. Is it resolved for you?