Complete the code to render the 'home' template using Express.
app.get('/', (req, res) => { res.[1]('home'); });
The res.render method tells Express to render a template file named 'home'.
Complete the code to pass a variable 'title' with value 'Welcome' to the template.
app.get('/', (req, res) => { res.render('home', { [1]: 'Welcome' }); });
The object passed as the second argument to res.render contains variables for the template. Here, title is the variable name.
Fix the error in the code to correctly render the 'profile' template with user data.
app.get('/profile', (req, res) => { const user = { name: 'Alice' }; res.[1]('profile', { user }); });
To render a template with data, use res.render and pass the data as an object.
Fill both blanks to render 'dashboard' template with a user name and age.
app.get('/dashboard', (req, res) => { res.render('dashboard', { [1]: 'Bob', [2]: 30 }); });
The template expects variables named name and age to display user info.
Fill all three blanks to render 'product' template with id, name, and price variables.
app.get('/product', (req, res) => { res.render('product', { [1]: 101, [2]: 'Book', [3]: 9.99 }); });
The template uses id, name, and price to show product details.