Heh heh. Your like most coders - and I hate to break it to you - that’s not how you do it! You may only use Node.js on a server file, not on the actual website. You might’ve thought that EMCAscript had this. They don’t, but there are types like in TypeScript. You will have to send data through, or use this
var maxNumber = 10 // or anything, really
var random_number = Math.floor(Math.random() * maxNumber);
you could also do
function randomNum(num) {
return Math.floor(Math.random() * num); // every time the function is ran, return a random value
}
and use it like
var num = randomNum(100); // let's say the value is 67
alert(num) // alerts 67 to the user
If you want to use that package you should check out a bundler like parcel (simpler) or webpack. There are also other options with names I forgot. Bundling some modules can cost a lot and some modules cannot be bundled. You can check for those things using this website
Pretty sure a random number function should require no apis unless it’s calling a system random number function
Do you know about DOM selectors like getElementById and getElementsByClassName? Don’t use document.write - it adds unsafed code that people can use to insert viruses. Try making an element and writing to that with .innerText.