I have this problem I'm not really sure how to do it. I'm having trouble figuring out how to add items to an array using a function that generates random numbers.
First I have to build a function that takes three parameters. one is the minimum random number, the other one is the maximum, the third parameter is the length of the array.
I've tried some stuff like removing the variable x setting it to an empty array.
var newArray = [generateRandomArray(10, 1, 10)]
function getRandomInt(min, max) {
return Math.floor(Math.random() * (
max + 1 - min)) + min;
}
var generateRandomArray = function(max, min, length) {
var x;
for (y = 1; y >= length; y++) {
x = [x.push(getRandomInt(min, max))]
console.log(x)
}
return x;
}
var newArray = [generateRandomArray(10, 1, 10)] returns [5, 7, 9, 6, 6, 10, 8, 10, 9, 7]
I just get []