1
Below this my function of Node.js (I’m new at this), I would like to fill the array with random numbers (could be with everything else), is there any faster way to do this ? Of what I’m doing ?
QLearn.reset = function() {
for (var a=0; a<100; a++) {
for (var b=0; b<20; b++) {
for (var c=0; c<100; c++){
for (var d=0; d<QLearn.action; d++){
QL[a,b,c,d]=Math.random();
}
}
}
}
It is unclear what result you want to get... do you want to create a new array or modify an existing array? The array is of a single dimension or has arrays inside arrays?
– Sergio
Are arrays inside arrays
var QL = [[],[],[],[]];
I want the function to initialize the array and fill it with random numbers. The important thing is that it does so as quickly as possible.– Luiz
And the random numbers are any or between a default value? How many numbers per array?
– Sergio
ranging from 0 to 1 would be good, even if it was only with zeros would already be interesting, the important thing is that it is fast.
– Luiz
Okay, did you see my answer? That’s what you were looking for?
– Sergio
I was wondering, I’d still have to put
for (var a=0; a<100; a++) {
 for (var b=0; b<20; b++) {
 for (var c=0; c<100; c++){
????– Luiz
My code supersedes all these
for
. The result is an array, with arrays inside, each with four random numbers from 0 to 1.– Sergio