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 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 15,450 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!