How can I fill out a two-dimensional arrangement in Javascript?

0

I have a function that with a for runs a CATEGORY in my database, then a nested for PRODUCTS within that CATEGORY . Then I make a reference to my database extracting the PRODUCTS from the whole CATEGORY Finishing the routes I show my data in console to verify if they are correct, after printing my bidimencionales fixes full where the first index is my category and the second my products but it marks me errors. I guess in filling my arrangements. Is the correct way to fill two-dimensional arrays?

 function obtenerDatos(){

 var nombre;
 var precio ;
 var status;


 for(var k=1; k<=numeroCategoriasBebidas; k++){ 




     for(var j=1; j<=numeroProductosBebidas[k]; j++){

                var productoStr = "Producto" + j;
                var productoReference = 
             categoriasReference[k].child(productoStr);


                   productoReference.on('value', snap => {

                    nombre=snap.child("nombre").val();

                           precio=snap.child("precio").val();

                            status= snap.child("status").val();


                     console.log(nombre + "     " + "$" + precio + "     " + status);

                             nombreProductosBebidas[k][j] = nombre;
                                precioProductosBebidas[k][j] = precio;
                                statusProductosBebidas[k][j] = status;


                             });



        }



    }


}
    
asked by Packvt 31.01.2018 в 00:27
source

0 answers