Challenge - 5 Problems
Express Structure Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What is the output of this Express route handler?
Consider this Express route handler code. What will the client receive when accessing
/hello?Express
const express = require('express'); const app = express(); app.get('/hello', (req, res) => { res.send('Hello, world!'); }); app.listen(3000);
Attempts:
2 left
💡 Hint
Look at what the
res.send method sends back.✗ Incorrect
The res.send method sends the string directly as the response body. So the client will see 'Hello, world!'.
📝 Syntax
intermediate2:00remaining
Which option correctly sets up a middleware in Express?
You want to add a middleware that logs every request method and URL. Which code snippet correctly does this?
Attempts:
2 left
💡 Hint
Express uses a specific method to add middleware functions.
✗ Incorrect
The app.use method adds middleware. The middleware must call next() to continue the request cycle.
🔧 Debug
advanced2:00remaining
Why does this Express app crash on startup?
Examine the code below. Why does the server crash when you run it?
Express
const express = require('express'); const app = express(); app.get('/test', (req, res) => { res.send('Test route'); }); app.listen(3000); console.log('Server started');
Attempts:
2 left
💡 Hint
Check the parentheses in the
app.listen line.✗ Incorrect
The app.listen call is missing a closing parenthesis, causing a syntax error and preventing the server from starting.
❓ state_output
advanced2:00remaining
What is the value of
count after these requests?Given this Express app, what is the value of
count after three GET requests to /count?Express
const express = require('express'); const app = express(); let count = 0; app.get('/count', (req, res) => { count += 1; res.send(`Count is ${count}`); }); app.listen(3000);
Attempts:
2 left
💡 Hint
Each request increases
count by 1.✗ Incorrect
The variable count starts at 0 and increments by 1 on each request. After 3 requests, it becomes 3.
🧠 Conceptual
expert2:00remaining
Which statement best describes Express app structure?
Which of the following best describes the typical structure of an Express application?
Attempts:
2 left
💡 Hint
Think about how to keep code organized and maintainable.
✗ Incorrect
Express apps are usually organized by separating routes and middleware into different files to keep code clean and manageable.