gpt-3.5-turbo-0125· openai
from WildChat-4.8M
Write a 10 nodejs usefull code with your imagination
- User
Write a 10 nodejs usefull code with your imagination
- Assistant
- A simple HTTP server that responds with a "Hello, World!" message:
javascriptconst http = require('http'); http.createServer((req, res) => { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello, World!\n'); }).listen(3000); console.log('Server running at http://localhost:3000/');- A script that reads a file and logs its contents to the console:
javascriptconst fs = require('fs'); fs.readFile('example.txt', 'utf8', (err, data) => { if (err) throw err; console.log(data); });- A program that generates a random number between 1 and 100:
javascriptconst randomNum = Math.floor(Math.random() * 100) + 1; console.log(randomNum);- A script that makes a request to an API and logs the response:
javascriptconst https = require('https'); https.get('https://api.example.com/data', (resp) => { let data = ''; resp.on('data', (chunk) => { data += chunk; }); resp.on('end', () => { console.log(JSON.parse(data)); }); }).on('error', (err) => { console.error(err); });- A function that calculates the factorial of a number:
javascriptfunction factorial(num) { if (num === 0 || num === 1) { return 1; } else { return num * factorial(num - 1); } } console.log(factorial(5)); // 120- A program that reads user input from the console and logs it:
javascript
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.