Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Express Basics Parameters, Query Strings, and Modularizing Routes Randomize Cards

Url issues

I understand his solution, but I'm wanted some insight as to why my solution isn't working.

I handled the majority of the logic in Pug, and the only thing not working is when I include the "?" in the code (inlcuded below), everything after it disappears when the request is made. When I omit it, the url renders completely, but without the "?". So I end up with an error because it's not included in the url. What am I missing?

  if side === 'question'
            form(action= `${id}?side=answer` method='get')
              button(type='submit') Answer

              form(action= `${id}?side=question` method='get')
                button(type='submit') Question

A question mark is a special character in JavaScript try escaping the question mark with a backslash /?

1 Answer

13,313 Points

I had the same issue and had to replace the buttons with normal links

if(side === "question")
        h2= prompt
        h2= text
        if hint
                i Hint: #{hint}
        a(href=id + "?side=answer") Answer
    if(side === "answer")
        h2 The answer is:
        h2= text
        a(href=id + "?side=question") Question