Category : random

So, I’ve never seen this before and can’t find documentation on this. There is a randomly generated code associated with each of the javascripts running on a WordPress site I am working on. I have no idea what is generating this, but it could be causing some javascript conflicts. It appears like this: <script type="f9dacaae4ee41613fcbad81d-text/javascript">// ..

Read more

so I had this express.js code. As shown below: const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; const randomMonth = months[Math.floor(Math.random() * months.length)]; app.get(‘/v1/month’, (req, res) => { res.json({ month: randomMonth }) }); But what happens is I always get the same response which is {"month":"July"}. How do ..

Read more

I am writing a method which should generate n random colors without repetition, passing the following properties. random({ number: 150, colors: ["blue", "lightBlue", "cyan"], shades: ["200", "500"] //excludeColors: ["blue", "lightBlue", "cyan"], //excludeShades: ["200", "500", "700", "A700"] }); The colors are the ones used using @material-ui/core/colors, but I would like to improve the function to make ..

Read more

I did a magic 8 ball for practice with JavaScript, and then someone told me if I could link the answers with an audio file that says exact the same that is displayed. I’ve been searching the web and I couldnt find an answer. I don’t know how to link a Math.random list of the ..

Read more

I’m making a generator of random arrays shuffling one initial array multiple times. SHUFFLE FUNCTION let currentIndex = array.length, temporaryValue, randomIndex; while (0 !== currentIndex) { randomIndex = Math.floor(Math.random() * currentIndex); currentIndex -= 1; temporaryValue = array[currentIndex]; array[currentIndex] = array[randomIndex]; array[randomIndex] = temporaryValue; } return array; } GENERATE CHROMOSOMES(This function generates an array of arrays ..

Read more