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 Using Templates with Express Using Logic in Pug

Wendy Cortes
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Wendy Cortes
Full Stack JavaScript Techdegree Graduate 16,375 Points

Can only set one object property

Hey everyone, when I create the prompt variable, everyone seems to work fine in app.js. But the hint variable is not showing no matter what!

This is what the card.pug looks like:

doctype html
html(lang="en")
  head
    title Flash Cards
  body
    header
        h1 Flash Cards
    section#content
        h2= prompt
        i hint #{hint}
    footer
        p An app to help you study 

And this is app.js

const express = require('express');

const app = express(); 

app.set('view engine', 'pug')


app.get("/", (req, res)=>{
    res.render("index");
});
app.get("/cards", (req, res)=>{
    res.render("card", {prompt: "Who is buried in Grant's tomb?", hint: "Think of whose tomb it was"});
});

app.listen(3000, ()=> {
    console.log("The application is running on localhost:3000!")
});

What am I doing wrong? :(

1 Answer

Rohald van Merode
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Rohald van Merode
Treehouse Staff

Hi Wendy Cortes 👋

Judging from those snippets I don't think there's anything wrong in your code. The only thing that looks different compared to Andrews code is that your i tag isn't nested inside a p tag. But this shouldn't stop your code from being rendered. You might want to stop and restart the server to see the changes rendered to the page 🙂

Hope this helps!