Hi everyone! Excited to be here!
I'm working on a basic JavaScript 'app' that just runs in the JS console on my browser. I'm trying to figure out how to generate random numbers as a part of it, but am having a hard time.
Any suggestions?
Hi everyone! Excited to be here!
I'm working on a basic JavaScript 'app' that just runs in the JS console on my browser. I'm trying to figure out how to generate random numbers as a part of it, but am having a hard time.
Any suggestions?
For further actions, you may consider blocking this person and/or reporting abuse
minhaalex -
Dorian Sabitov -
owensmith -
Bisharat Khan -
Latest comments (3)
Hi Hailey! We are happy that you joined the coders community! Welcome!
This is a function to get random numbers from 0 to 10:
const randomNumbers = () => Math.floor(Math.random() * 10);
Hi! The way I do it is by using the "random" function on the built-in Math object. There are a bunch of great examples on MDN, but in a nutshell:
This ^^^
Also, you can write (Math.random() * x) + 1 to generate a number between 1 and x.