I've been trying to store local variable's value into Global variable, but that just doesn't seem to work. Any help on this?
var xv = 0;
var yv = 0;
var itemx = firebase.database().ref().child("item").child("xval");
itemx.on('value', function(xvalue){
xv = xvalue.val();
});
var itemy = firebase.database().ref().child("item").child("yval");
itemy.on('value', function(yvalue){
yv = yvalue.val();
});
var start = graph.grid[aa][bb];
var end = graph.grid[xv][yv];
var result = astar.search(graph, start, end);
I'm unable to fetch the values of variables xv and yv outside the Firebase function.