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

Samuel Llibre-Pillco
Samuel Llibre-Pillco
15,467 Points

This is how i make the exercise of table

Here is how i resolve the exercise of making table with a loop and pug

const express = require('express');

const app = express();

const names = [
    {name: 'Samuel ',
    lastName: 'Llibre Santos '},
    {name:'Aleksandra ',
    lastName:'Breway '},
    {name:'Wendy ',
    lastName:'Elton '},
    {name:'Elaine ',
    lastName:'Brightburn '},
    {name:'Samantha ',
    lastName:'Fleck '},
];

app.get('/sandbox', (req, res) => {
    res.render('sandbox', {names});
});

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

And here is the pug file

doctype html
html(lang="en")
  head
    title Sandbox
  body
    header
        h1 Sandbox
    section#content
        table(style='width:100%', border='1')
            tr  
                th First Name
                th Last Name 
            each name in names
                tr
                    th= name.name 
                    th= name.lastName
    footer
        p An app to help you study

Want to know how other student do it ;).

Andrew Chalkley