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
CodeNewbie Staff -
Tip Season -
Tyler V. (he/him) -
𝕁𝕦𝕝𝕚𝕒 👩🏻💻 -
Once suspended, thecomet will not be able to comment or publish posts until their suspension is removed.
Once unsuspended, thecomet will be able to comment and publish posts again.
Once unpublished, all posts by thecomet will become hidden and only accessible to themselves.
If thecomet is not suspended, they can still re-publish their posts from their dashboard.
Discussion (3)
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.
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);