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
Ashish Mehra
Courses Plus Student 589 Pointsfinally completed my lightbox code
check out here http://codepen.io/mehra_as/pen/rxrBMv
1 Answer
huckleberry
14,636 PointsHeeeey good job Ashisha!!
It looks really nice! :).
A couple of suggestions.
There's currently no way to exit out of the light box. I couldn't click the background or anything and have the picture go away and be back at the normal page view.
Try and think about more modular code and the whole DRY practice when you're coding. There are a lot of repeating and unnecessarily verbose code there in your JS. DON'T WORRY... that's completely normal at this stage in the game.
You're just learning that stuff and you have to approach it from that line of thinking first before you can start thinking modularly. Think about learning about words. First you have to learn the basics right? That may result in you taking 6 words to say what you could in 2. But as you learn more words (synonyms) you realizes that there are ways to say something with fewer words.
"I usually use a lot of words when I talk or type"
vs.
"I'm rather verbose"
See what I mean? Same thing, more compact. Much nicer.
So in your code you have a lot of repeating code that you could put into separate functions and use that as a callback later on. (take a look at some of those if statements ;)) and things happening across 3 or 4 lines that you could have done in 1 line. Now that you have done it your way (which again, totally OK and you did an awesome job.) now go back and "refactor" your code. Heh, new vocabulary for ya!
Here's a great great great little video tutorial series to watch about producing more modular JS code and aren't you in luck, he uses as an example a bunch of JS/jQuery code to show what he means!! Seriously, go watch that!
Anyway, great job and keep it up, champ!
Cheers,
Huck -