florinpop17 / topic-suggestions

A place to keep track of topic suggestions for my YouTube videos.
8 stars 1 forks source link

Random number betweet x and y #1

Open florinpop17 opened 4 years ago

florinpop17 commented 4 years ago

Create a tutorial showcasing how to generate a random number between 2 given numbers using JavaScript.

nucket commented 1 year ago

Hi

// define a function to determine random numbers between two values
function numRandom(min, max) {
        return Math.floor(Math.random() * (max - min + 1) + min)  
}

// call to the function in output
let output = numRandom(1,9)
// minimum number = 1
// maximum number = 9
console.log(output)

// number 1 ~ 9
7

I was just going through your repository of ideas and saw this other one with this query. Regards