var m = "a";
destination2 = [];
db.collection('DestinationDisplay').get().then((snapshot) => {
var i = 0;
snapshot.docs.forEach(doc => {
destination2[i] = doc.data().DestinationName;
$("a").click(function xyc(){
m = this.id;
console.log(m);
});
i+=1;
})});
console.log(m);
The last console.log() only shows 'a' while I need a number.