Creating a list of events will be straightforward. This will mirror how we'll get information from our MongoDB database in the future.

const events = [
  { name: 'Basketball', slug: 'basketball', description: 'Throwing into a basket.' },
  { name: 'Swimming', slug: 'swimming', description: 'Michael Phelps is the fast fish.' },
  { name: 'Weightlifting', slug: 'weightlifting', description: 'Lifting heavy things up' }

To loop over these and show them in the browser, we'll pass these to ejs and show them:

// return a view with data
res.render('pages/events', { events: events });

And in our view:

Table of Contents

    <% for (var event of events) { %>
            <td><%= %></td>
            <td><%= event.description %></td>
                <a href="/events/<%= event.slug %>" class="btn btn-sm btn-primary">View</a>
    <% } %>

    Chris Sevilleja

    176 posts

    Founder of Google Developer Expert in Web Technologies. Slapping the keyboard until something good happens.