function getoilnum(key){
var num;
var eRef = database.ref('dev_story/' + key + '/related_oils');
eRef.on('value', function(snapshot){
num = snapshot.val().length;
})
return num
}
Hi, there
I'm new to javascript, so I have a question. in this code, I have to get the value of num inside eRef as return value. But this code still prints 'undefined'.
How should I change this code?