I am working on a firebase project with vuejs, trying to draw a chart that shows the number of subscribers per month. The main issue is to just calculate the number of created profiles for each month. The rest of the steps will be okay with me.
I thought to do something like this:
// calculation of number of users each month
let months = ['jan', 'feb', 'mar', 'apr', 'may', 'Jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];
this.users.filter(user => {
let print = user.metadata.creationTime;
for (var month in months) {
if (print.indexOf(month) > -1) {
console.log(user.email)
}
}
})
I imagined it like this,.. but the console prints duplicated records for each month,..
I am thinking that there might be another way of doing it,.. or do I just stick with tweaking and trying with this one?
month of monthsrather thanin. Currently you're iterating the numeric indices. I would also note thatJunis not in the same case as the other months. Also unclear why you're usingfilter, seems unlikely to be the appropriate iterator.for...ofis meant more for array andfor...inis meant more for objects' keys.filteris meant to return some object(s) based on certain criteria, and it doesn't look like you're attempting that. Can you provide more context as well?