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 trialKyle Vassella
9,033 Pointsmad libs Final Project over complicated? (Javascript beginner lesson)
Hi all,
I'm on this lesson: https://teamtreehouse.com/library/javascript-basics/storing-and-tracking-information-with-variables/the-variable-challenge-solution
The goal is to make a 'Mad Libs' type game using inputs from several prompts to write a text message story onto the webpage using their words.
When I completed my code and checked the 'how to' video and was pretty surprised at how different his code was than mine. Mine still served the same purpose as his code - the only difference was that mine showed up in smaller font (still appeared in the same place though:
My code: https://w.trhou.se/v4hb8mm3n7
His code: https://w.trhou.se/d7tgd62rm4
Do you think the instructor only added all these extra steps (a 'sentence' variable?? Seemed pointless to me) to give us more practice writing variables? Or was there a reason for the added complexity to his code? If so, what makes my code incorrect for this application?
- Kyle
1 Answer
anil rahman
7,786 PointsHe probably used the sentence variable to add in the <h2> tags and also to do all the sentence construction in the program and not the write function. Theres nothing wrong with either way of doing things, his just does the work before calling the function and adds in the tags also. Also he probably was trying to show the way you can append the string.