0
0
Expressframework~10 mins

What is Express - Interactive Quiz & Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a basic Express app.

Express
const express = require('[1]');
const app = express();
Drag options to blanks, or click blank then click option'
Apath
Bexpress
Cfs
Dhttp
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'http' instead of 'express' to create the app
Forgetting to require the express module
2fill in blank
medium

Complete the code to start the Express server on port 3000.

Express
app.listen([1], () => {
  console.log('Server running on port 3000');
});
Drag options to blanks, or click blank then click option'
A8080
B5000
C3000
D80
Attempts:
3 left
💡 Hint
Common Mistakes
Using a port number different from 3000 without updating the message
Passing a string instead of a number
3fill in blank
hard

Fix the error in the route handler to send 'Hello World' as response.

Express
app.get('/', (req, res) => {
  res.[1]('Hello World');
});
Drag options to blanks, or click blank then click option'
Asend
Bwrite
Cend
DwriteHead
Attempts:
3 left
💡 Hint
Common Mistakes
Using Node.js response methods like write or end instead of Express's send
Forgetting to send a response
4fill in blank
hard

Fill both blanks to create a JSON response with Express.

Express
app.get('/data', (req, res) => {
  res.[1]({ message: 'Hello' });
  res.[2]();
});
Drag options to blanks, or click blank then click option'
Ajson
Bsend
Cend
Dwrite
Attempts:
3 left
💡 Hint
Common Mistakes
Calling send after json which can cause errors
Not ending the response
5fill in blank
hard

Fill all three blanks to create a middleware that logs request method and URL.

Express
app.use(([1], [2], [3]) => {
  console.log(`$[1].method $[2].url`);
  next();
});
Drag options to blanks, or click blank then click option'
Areq
Bres
Cnext
Drequest
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong parameter names
Forgetting to call next() to continue