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 Linking Around the Application

2 Answers

Jelena Feliciano
seal-mask
.a{fill-rule:evenodd;}techdegree
Jelena Feliciano
Full Stack JavaScript Techdegree Student 12,729 Points

This definitely works but it also seems like the !side and the parentheses wrapped around the side !== 'answer' && side !== 'question' are no longer needed and it looks much easier to read.

if (  side !== 'answer' && side !== 'question' ) {
    res.redirect(`/cards/${id}?side=question`)
  }

This was really helpful.

Tron Nguyen
Tron Nguyen
10,847 Points
  if(side === 'question'){
    templateData.hint = hint;
    templateData.sideToShow = 'answer';
    templateData.sideToShowDisplay = 'Answer';
  }else if(side === 'answer'){
    templateData.sideToShow = 'question';
    templateData.sideToShowDisplay = 'Question';
  }else{
    return res.redirect(`/cards/${id}?side=question`);
  }