I am trying to ForEach loop through data from a FireStore database and push it into an array. I am having some very strange issues though. The FireStore connection is irrelevant for now though, as I have taken to manually trying to make an array inside and outside a ForEach loop with the same array.push code, and the array built from inside the loop does not function correctly. It shows in Chrome as some sort of object/array with the length of 0 (yet still with content), while the exact same code built outside the ForEach block works fine. I am attach a screen shot that explains the issue.
Been racking my brain on this for hours, so any help is appreciated.
var HTRequirementsArray = [];
var ReqArray = [];
db.collection('requirements').get().then((snapshot) => {
snapshot.docs.forEach(doc => {
HTRequirementsArray.push(["1", "2", "3"]);
})
})
ReqArray.push(["1", "2", "3"]);
ReqArray.push(["1", "2", "3"]);
ReqArray.push(["1", "2", "3"]);
HTRequirementsArray does not work correctly.