Loading

Quipoin Menu

Learn • Practice • Grow

express-js / Express.js Serving Dynamic Content
mcq
Direction: Choose the correct option

Q1.

How do you pass data to a template for rendering?
A. Use app.locals
B. Use res.locals
C. Pass an object as the second argument to res.render()
D. All of the above
Direction: Choose the correct option

Q2.

What is the purpose of app.locals?
A. To define local routes
B. To configure the app
C. To store data that is available to all templates across the application
D. To store local variables for a single request
Direction: Choose the correct option

Q3.

How can you make data available to a single request's views without passing to res.render?
A. Use global variables
B. Set properties on res.locals
C. Use app.locals
D. Set properties on req.locals
Direction: Choose the correct option

Q4.

Given res.render('index', { title: 'Home' }), how do you access title in an EJS template?
A. <%= locals.title %>
B. <%= this.title %>
C. <%= title %>
D. <%= data.title %>
Direction: Choose the correct option

Q5.

What does res.render() return?
A. It returns a promise
B. It sends the rendered HTML as the response
C. It returns a string
D. It returns the view object