gpt-4.1-mini-2025-04-14· OpenAI
WildChat-4.8M (AI2)
js log random(min,max)
- User
js log random(min,max)
- Assistant
If you want a JavaScript function to log a random number between
minandmax, here's a simple example:function logRandom(min, max) { // Generate random number between min (inclusive) and max (inclusive) const random = Math.random() * (max - min) + min; console.log(random); }Usage:
logRandom(1, 10); // Logs a random decimal number between 1 and 10If you want only integers:
function logRandomInt(min, max) { // Generate random integer between min and max (both inclusive) const randomInt = Math.floor(Math.random() * (max - min + 1)) + min; console.log(randomInt); }Usage:
logRandomInt(1, 10); // Logs a random integer between 1 and 10Let me know if you want it differently!