Currently, I am in the process of creating an array structured like so:
var p1_s1 = {
'title': 'p1_s1', 'titleDisplayed': 'p1_s1', 'type': 'numbers', 'page':1,'strings': 1, 'length': 7, 'placeholder':'0000000', 'painted':'black', 'notPainted':'#ffe485', 'left':410, 'top':161, 'width':394, 'height':144,
'ids':[
['path5472','path5440','path5488','path5520','path5504','path5456','path5536'],
['path5360','path5328','path5376','path5408','path5392','path5344','path5424'],
['path5584','path5552','path5600','path5632','path5616','path5568','path5648'],
['path4912','path4880','path4928','path4960','path4944','path4896','path4976'],
['path5024','path4992','path5040','path5072','path5056','path5008','path5088'],
['path5136','path5104','path5152','path5184','path5168','path5120','path5200'],
['path5248','path5216','path5264','path5296','path5280','path5232','path5312']
]
};
Subsequently, within my script code, I make use of this variable by calling it:
...
var ids = p1_s1['ids'];
for(var i = ids.length;i>=0;i--)
{
drawOneNumber( ids[i], parseInt(value[i]) );
}
...
function drawOneNumber( place, number )
{
number = numberToSegments( number );
console.log(place);
for(var i=0;i<number.length;i++)
{
console.log( place[i] );
}
...
}
Upon utilizing console.log(place);
, the array is outputted on the console as expected.
(7) […]
0: "path5248"
1: "path5216"
2: "path5264"
3: "path5296"
4: "path5280"
5: "path5232"
6: "path5312"
length: 7
However, when attempting to log place[i]
, an error occurs:
TypeError: place is undefined
The same issue arises with the following code snippet:
place.forEach(element => console.log(element));
Even though Array.isArray(place);
returns true, manipulating this variable as an array seems to be problematic.
Could you please advise on where I might be going wrong?
Thank you.