Go adding values from for into array

0

I created an array:

var tagListArray = [];

 for(i = 0; i<resultados.item(i); i++){
    tagListArray = ["valor1", "valor2"];
 }

console.log(tagListArray);

This resultados.item(i) returns me values, how do I add them to the array?

I did so to test:

var tagListArray = ["Maçã", "Banana"];
                                var data = new Object({data:[]});
                                var index;  

                                for(index = 0; index < results.rows.length; index++) {
                                    alert(results.rows.item(index).descricao);
                                    data.data.push({
                                        tag: tagListArray[index]
                                    });
                                };

But in the tagListArray I want the values to be filled with what the loopback returns.

    
asked by anonymous 08.11.2018 / 14:37

1 answer

0

Use the push() command to add a new item in array :

tagListArray.push("String");

If it's an object list you can use it anyway:

tagListArray.push({
  ID: 1,
  Nome: "Valor 1"
});
    
08.11.2018 / 14:45