How do I store all the values that are passed by the for in a variable?

-3

I have this code:

for(i=0; i<results.rows.length; i++){
    $('.chips').material_chip({
        data: [
            {tag: results.rows.item(i).descricao},
        ]
    }); 
}

results.rows.item(i).descricao returns me some values ..

How do I save all of these values in a single variable?

EX: var exemplo = valor1, valor2... , all the values it found in for . Is it possible?

    
asked by anonymous 07.11.2018 / 12:31

1 answer

2

You can save to an array

let descricoes = []

for(i = 0; i < results.rows.length; i++){
  $('.chips').material_chip({
    data: [
      {
        tag: results.rows.item(i).descricao
      },
    ]
  });

  // Aqui eu preencho o array
  descricoes.push(results.rows.item(i).descricao)
}
    
07.11.2018 / 12:37