Skip to content

Instantly share code, notes, and snippets.

@rogeruiz
Last active December 14, 2023 00:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogeruiz/c5e4ce65ef47076fe4e2 to your computer and use it in GitHub Desktop.
Save rogeruiz/c5e4ce65ef47076fe4e2 to your computer and use it in GitHub Desktop.
Now for something completely random
const MAX = 39;
const MIN = 33;
const COUNT = 200;
const nn = new Array(COUNT).fill();
/**
* @param {any[]} a - An array to be used to create a new array of random
* values. The contents of the array is not modified.
* @returns {number[]} - An array of the same length passed in with random
* numbers at each index
*/
const generateRandomness = (a) => {
return a.map((_) => {
return (Math.random() * (MAX - MIN) + MIN).toFixed(0);
});
};
const dd = generateRandomness(nn);
console.log(`[${dd.join(", ")}]`);
console.log(`Total random numbers: ${dd.length}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment