0
0
Expressframework~10 mins

Creating a basic Express server - Interactive Practice

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

Complete the code to import the Express library.

Express
const express = require('[1]');
Drag options to blanks, or click blank then click option'
Aexpress
Bhttp
Cfs
Dpath
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'http' instead of 'express' to import Express.
Forgetting to put the library name in quotes.
2fill in blank
medium

Complete the code to create an Express application instance.

Express
const app = [1]();
Drag options to blanks, or click blank then click option'
Aapp
Bexpress
Cserver
Dhttp
Attempts:
3 left
💡 Hint
Common Mistakes
Calling a variable named 'http' instead of 'express'.
Trying to call 'app()' before defining it.
3fill in blank
hard

Fix the error in the code to make the server listen on port 3000.

Express
app.[1](3000, () => {
  console.log('Server is running on port 3000');
});
Drag options to blanks, or click blank then click option'
Alisten
Bstart
Crun
Dopen
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'start' or 'run' which are not Express methods.
Forgetting to call the method as a function.
4fill in blank
hard

Fill both blanks to define a GET route for the root URL that sends 'Hello World!'.

Express
app.[1]('[2]', (req, res) => {
  res.send('Hello World!');
});
Drag options to blanks, or click blank then click option'
Aget
Bpost
C/
D/home
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'post' instead of 'get' for the route method.
Using '/home' instead of '/' for the root URL.
5fill in blank
hard

Fill all three blanks to import Express, create an app, and start the server on port 4000.

Express
const [1] = require('[2]');
const app = [3]();
app.listen(4000, () => {
  console.log('Server running on port 4000');
});
Drag options to blanks, or click blank then click option'
Aexpress
Dhttp
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'http' instead of 'express' in require.
Using different variable names inconsistently.