NodeJS challenges
Practice problem statements with input format, output format, constraints and solutions.
Node Introduction challenge
Build a small solution that uses Node Introduction in NodeJS and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
import express from "express";
const app = express();
app.get("/api/node-introduction", (req, res) => res.json({ ok: true, feature: "Node Introduction" }));
app.listen(3000);Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core node introduction pattern before polishing the final output.
Solution
import express from "express";
const app = express();
app.get("/api/node-introduction-solution", (req, res) => res.json({ ok: true, feature: "Node Introduction solution" }));
app.listen(3000);Modules challenge
Build a small solution that uses Modules in NodeJS and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
import express from "express";
const app = express();
app.get("/api/modules", (req, res) => res.json({ ok: true, feature: "Modules" }));
app.listen(3000);Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core modules pattern before polishing the final output.
Solution
import express from "express";
const app = express();
app.get("/api/modules-solution", (req, res) => res.json({ ok: true, feature: "Modules solution" }));
app.listen(3000);NPM challenge
Build a small solution that uses NPM in NodeJS and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
import express from "express";
const app = express();
app.get("/api/npm", (req, res) => res.json({ ok: true, feature: "NPM" }));
app.listen(3000);Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core npm pattern before polishing the final output.
Solution
import express from "express";
const app = express();
app.get("/api/npm-solution", (req, res) => res.json({ ok: true, feature: "NPM solution" }));
app.listen(3000);File System challenge
Build a small solution that uses File System in NodeJS and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
import express from "express";
const app = express();
app.get("/api/file-system", (req, res) => res.json({ ok: true, feature: "File System" }));
app.listen(3000);Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core file system pattern before polishing the final output.
Solution
import express from "express";
const app = express();
app.get("/api/file-system-solution", (req, res) => res.json({ ok: true, feature: "File System solution" }));
app.listen(3000);Events challenge
Build a small solution that uses Events in NodeJS and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
import express from "express";
const app = express();
app.get("/api/events", (req, res) => res.json({ ok: true, feature: "Events" }));
app.listen(3000);Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core events pattern before polishing the final output.
Solution
import express from "express";
const app = express();
app.get("/api/events-solution", (req, res) => res.json({ ok: true, feature: "Events solution" }));
app.listen(3000);ExpressJS challenge
Build a small solution that uses ExpressJS in NodeJS and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
import express from "express";
const app = express();
app.get("/api/expressjs", (req, res) => res.json({ ok: true, feature: "ExpressJS" }));
app.listen(3000);Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core expressjs pattern before polishing the final output.
Solution
import express from "express";
const app = express();
app.get("/api/expressjs-solution", (req, res) => res.json({ ok: true, feature: "ExpressJS solution" }));
app.listen(3000);REST API challenge
Build a small solution that uses REST API in NodeJS and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
import express from "express";
const app = express();
app.get("/api/rest-api", (req, res) => res.json({ ok: true, feature: "REST API" }));
app.listen(3000);Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core rest api pattern before polishing the final output.
Solution
import express from "express";
const app = express();
app.get("/api/rest-api-solution", (req, res) => res.json({ ok: true, feature: "REST API solution" }));
app.listen(3000);Middleware challenge
Build a small solution that uses Middleware in NodeJS and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
function requireUser(req, res, next) {
if (!req.headers.authorization) return res.status(401).json({ error: "Login required" });
next();
}Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core middleware pattern before polishing the final output.
Solution
function requireUser(req, res, next) {
if (!req.headers.authorization) return res.status(401).json({ error: "Login required" });
next();
}Routing challenge
Build a small solution that uses Routing in NodeJS and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
import express from "express";
const app = express();
app.get("/api/routing", (req, res) => res.json({ ok: true, feature: "Routing" }));
app.listen(3000);Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core routing pattern before polishing the final output.
Solution
import express from "express";
const app = express();
app.get("/api/routing-solution", (req, res) => res.json({ ok: true, feature: "Routing solution" }));
app.listen(3000);Error Handling challenge
Build a small solution that uses Error Handling in NodeJS and handles one normal case plus one edge case.
Input format
Use a short text value, array, query, or sample object depending on the topic.
Output format
Print, render, or return the processed result in a readable format.
Constraints
- Keep the solution under 60 lines.
- Use descriptive names.
- Do not depend on hidden external services.
Starter code
import express from "express";
const app = express();
app.get("/api/error-handling", (req, res) => res.json({ ok: true, feature: "Error Handling" }));
app.listen(3000);Test cases
- basic sample - valid processed result
- empty or small sample - safe fallback result
Hint
Focus on the core error handling pattern before polishing the final output.
Solution
import express from "express";
const app = express();
app.get("/api/error-handling-solution", (req, res) => res.json({ ok: true, feature: "Error Handling solution" }));
app.listen(3000);