I am working with a variable that contains an array of comments.
$scope.numOfCommentsCoupon
What I want to do is create a variable that counts the number of comments in the array that have a specific "couponId
" value.
Here is the structure of the Comment Model:
var CommentSchema = new Schema({
created: {
type: Date,
default: Date.now
},
couponId: {
type: String,
trim: true
}
});
I need to filter through the array and then calculate the count, but I'm unsure of how to accomplish this.