I am facing an issue with storing objects in an array within a function. Every time the function is called, a new object is received and I want to add it to the existing array without overwriting the previous objects. This way, all the objects can be accessed and printed using a for loop.
drawtimeline(i_items, nom_cal, _hitoService, idcalbuscador) {
var container = document.getElementById('timeLine');
var result: any[] = [];
result.push({ "_id": this.idcalbuscador, "title": nom_cal });
for (let i of result) {
console.log(i);
alert(i);
}
}