I am encountering an issue with the Array.map function that is not behaving as expected. Below is a simplified example to help me understand where I am going wrong.
Here is the code snippet in question:
console.log(this.reportTestData)
let data = this.reportTestData.map((row) => {
return [ 1 , 2, 3]
});
console.log(data)
return data
Upon logging this.reportTestData, it is an array with 92 objects, where the content of each object is not relevant:
https://i.sstatic.net/ZOm54.png
Based on the code, I expected the map function to iterate over the array 92 times and produce a new array ([1,2,3]) for each element. This should result in an array of 92 elements, with each element being a [1,2,3] array. However, this is not the output I am receiving.
https://i.sstatic.net/xKwbY.png
Instead of an array with filled elements, I am getting an array of 92 empty elements.
As an alternative, I also attempted to return objects from the map function:
console.log(this.reportTestData)
let data = this.reportTestData.map((col) => {
return { test : 1 }
});
console.log(data)
return data
However, even in this case, I am getting empty objects without any properties:
https://i.sstatic.net/taTNU.png
Any assistance in identifying where my mistake lies would be highly appreciated, as I am unable to pinpoint the error myself.