Reputation: 196
function bodycreate(num)
{
var ref = database.ref('190/ExerciseTable/'+num+'/');
ref.on('value',gotdata,errData);
}
function gotdata(data)//passes firebase data
{
var ex3=you.val();
var sa3=Object.keys(ex3);
var s3=sa3.length;
console.log(s3);//prints count of child elements
console.log(num);//Here I want to print the variable num
}
I want to display the variable num. How can I get it from the parent function. Thanks in advance.
Upvotes: 0
Views: 53
Reputation: 3173
One which I can quickly think is
function bodycreate(num)
{
var ref = database.ref('190/ExerciseTable/'+num+'/');
ref.on('value',
function(data){
gotdata(data, num)
},errData);
}
And then change signature of gotdata
to receive two arguments.
Upvotes: 1