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 trialHenrik Christensen
Python Web Development Techdegree Student 38,322 PointsJavaScript project feedback :-)
Hi,
I've just finished a javascript project, and I'd love to get some feedback about the design and functionality before I begin my next project :-)
1 Answer
Daniel Landon Jr
14,733 Pointsit is advised that you should not use, or attempt to not use global variables. They can cause problems that can be difficult to find.
The code below is a way that I use that gets around this (i pulled this from another website a while back but sadly I do not have that site for reference).
const myApp = {};
(function() {
put code here
}).apply(myApp);
This acts like a namespace that you would find in Java. It encapsulates everything so that nothing is actually added to the global namespace.
Also, there are several places where you have some serious if statements going on. You should try to refactor your code so that there are not so many embedded if statements. Try going with more function declarations or some other approach. This will help in the maintenance and upkeep of your code. And it will make it easier to read/understand.
Please understand your code is "clean" looking and obviously functional, just a couple things pointed out that I would have tried to do differently.
Henrik Christensen
Python Web Development Techdegree Student 38,322 PointsHenrik Christensen
Python Web Development Techdegree Student 38,322 PointsThank you very much for the feedback :-)
I've never seen that "namespacing" before, but I will try have a look at it :-)