I took a look at your problem, and I think I have your solution, or at least PATHWAY for your solution. Ok, first I will explain the main problem, then I will try to provide you with generic-ish code (I will try to use some of the variables you use). And off we go!
Basically what I see is 2 steps ...
STEP 1 - you need to use the constructor function, which will create new user objects with their name (and / or user ID) and their own set of properties.
From this point of view, you can have a constructor function that includes properties such as "username", "match points 1", "match points 2", and then a function in which the console registers a summary of each name and their common points from the match points 1 and 2.
STEP 2. You need to place the constructor function inside the loop, which will go through the database, looking for specific properties needed to populate the properties needed by the constructor function, to highlight the information you are looking for.
So ... and let's take a deep breath, because it was a lot of words ... let's try to do it. I will use common properties in such a way that, in my opinion, it will be easier for you to insert your own property / variable names.
var user = function(name, match1, match2){ this.name = name; this.match1 = match1; this.match2 = match2; this.pointTotal = function(match1, match2) { console.log(match1 + match2);}; this.summary = function(){ console.log(name + " has a total of " + pointTotal + " points.");}; }
part of the "This" code allows you to use any username, not just certain ones.
Ok, so the above code takes care of part of the constructor function of the problem. Now it doesn’t matter how many users you need to create with unique names.
The next step is to create some kind of loop function that will go through the database and fill in the properties needed to create each user so that you can get total points from the EVERY user, and not just one.
Again, I will use generic-ish property / variable names ...
var key = childSnapshot.key; while(i = 0; i < key.length + 1; i++) { var user = function(name, match1, match2){ this.name = name; this.match1 = match1; this.match2 = match2; this.pointTotal = function(match1, match2) { console.log(match1 + match2);}; this.summary = function(){ console.log(name + " has a total of " + pointTotal + " points.");}; } }
This is a lot of words, and the code is a hybrid of common names / property variables and property names / variables used by you, but I'm sure I'm on the right track.
I have great confidence that if you used the code and EXPLANATION that I provided, then if you connect your own variables, you will get the solution you need.
In conclusion, I just want to say that I really hope that this helps, and if it is not, I would like to help solve the problem anyway, because I need practice. I work with strange watches, so if I don’t answer right away, I’ll most likely be in my work :(
Good luck and I hope that helped!