0
I have an array of objects:
window.matObj = [
{
id: 11,
x: aleatorio(3,9),
y: aleatorio(3,9),
resposta: (window.matObj[0].x + window.matObj[0].y),
enunciado: window.matObj[0].x + " + " + window.matObj[0].y
},
{
id:12,
x: aleatorio(3,9),
y: aleatorio(3,9),
resposta: (window.matObj[1].x + window.matObj[1].y)
},
];
However, when executing the application, it gives the following error:
Error in Undefined: Typeerror: Undefined is not an Object (evaluating 'window.matObj[0]')
I believe I’m referencing the attributes of each object (x
and y
) in the wrong way.
How the right way would be?
I wish I could do that too, make the code more readable
– Costamilam