FSD-I slip 2Create a Node.js file that will convert the output "Full Stack!" into reverse string
//Slip 2: Create a Node.js file that will convert the output "Full Stack!" into reverse string
const http = require('http');
const PORT = 3000;
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
const input = "Full Stack!";
const reversed = input.split('').reverse().join('');
// Send the output to the browser
res.end(`Original: ${input}\nReversed: ${reversed}`);
});
server.listen(PORT, () => {
console.log(`Server is running at http://localhost:${PORT}`);
});
Comments
Post a Comment