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 Express Basics Parameters, Query Strings, and Modularizing Routes Adding Links

I did it different. Is mine any worse or better? Maybe just different?

In the video, "Adding Links" with Andrew Chalkey the way he decides to change the site to make the hint appear based on the question was different than mine. I know there are always different ways to implement the same thing but theres usually a good better best. I want to know if I shouldn't be doing what I did. In my code I just passed the variable side that contained req.query.side onto the pug page so my const templeData = {text, hint, side} so then I went into the card.pug file and made in if clause that said if side == 'question' the hint will be displayed. I hope that makes sense. Any tips and constructive criticism is welcomed

2 Answers

James Crosslin
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
James Crosslin
Full Stack JavaScript Techdegree Graduate 16,882 Points

This is exactly how I solved this problem, and I do not see why we shouldn't do this. It seemed like the absolute simplest way to do this! We did not create any extra variables, we just took the data we already had and used an if statement. I think it will also come in handy later because we'll need to bring the id value in for links too. Anyone else who came up with this answer, you're doing okay in my book!

I had the same solution. But I also don't know if it is better or worse or just another solution. In my opinion it seemed much easier than what has been shown in the video.