I generate an array with js, and in terms of logic it generates it correctly as I require it, but when it is shown in the log, it interprets it as follows
When I unfold it, it shows me completely different data.
I don't understand why the browser interprets it that way, or if it's some kind of execution time error in my function; Basically it shows me the data of the last array in all.
I use this code to generate the array
let arrayData = [];
let arrayGeneral = [];
function genData(posicion){
arrayGeneral.length = 0;
let arrayPreguntas = auxPreguntasJson[0].preguntas.split(",");
let arrayProductos = auxPreguntasJson[0].productos.split(",");
for(let q=0;q<pregSeleccionadas;q++){
let auxColor = colorRGB();
for(let i=0;i<dataRespuestas.length;i++){
arrayData.length = 0;
let respuesta = dataRespuestas[i].respuestas;
let fecha = dataRespuestas[i].fecha;
let arrayRespuestas = respuesta.split(',');
let respPregunta = arrayRespuestas[posicion];
let day = fecha.substring(8);
for(let q=arrayLapsos[0];q<=arrayLapsos[arrayLapsos.length - 1];q++){
let dia = q;
if(parseInt(day) == dia){
console.log("es igual "+parseInt(day)+"**"+dia);
arrayData.push(parseInt(respPregunta));
}else{
arrayData.push(0);
}
}
console.log(arrayData)
arrayGeneral.push(arrayData);
//console.log(arrayGeneral)
}
}
//console.log(dataRespuestas)
console.log(arrayGeneral);
}