Complete the code to import the built-in HTTP module in Node.js.
const http = require([1]);The built-in HTTP module in Node.js is imported using require("http").
Complete the code to create a simple HTTP server that listens on port 3000.
http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World');
}).[1](3000);The method to start the server listening on a port is listen.
Fix the error in the code to correctly import the 'fs' module.
const fs = require([1]);The correct module name for file system operations in Node.js is "fs".
Fill both blanks to create a server that responds with JSON data.
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': [1] });
res.end(JSON.stringify({ message: [2] }));
});The content type for JSON data is "application/json". The message string can be any text, here 'Hello'.
Fill all three blanks to export a function named 'startServer' from a module.
function [1]() { console.log('Server started'); } module.exports = [2] = [3];
The function name and the exported name should match and be 'startServer'.
