I am working on fetching specific values from my 'snapshot' and storing them if they exist. Below is the snippet of my code:
function paydata(){
firebase.database().ref("pay/0/0/").once('value', function(snapshot){
var resp = [];
resp.push(snapshot.val());
console.log(resp); //outputs entire database
for(var i=0; i<resp[0].length; i++){
if(resp[0][i]["Employee"] == "22729805418" && resp[0][i]["Type"] == "AC bill"){
console.log(resp[0][i]); //does not print even if conditions are met
//I also want to display these values in an HTML table
var row = table.insertRow(table.rows.length);
var cell = row.insertCell(0);
var cell1 = row.insertCell(0);
cell.innerText = resp[0][i]["Actual amount"];
cell1.innerText = resp[0][i]["Current reading"];
}
}
})
console.log(table); //does not get printed
}
paydata();
This is how my complete database looks like:
How can I extract those specific values that meet the 'if' condition and then insert them into an 'HTML' table?