may help you . Your approach is wrong. Your Height class appears to be responsible for the evaluation of the mean value. Hence, you should put all values inside a single Height instance, instead of generating a new instance for each user value. However, h is an array of Heights object, while print() method is defined on a single Height instance. In order to call such method, you have to access one of the objects contained in h, that is h.print().
MongoDB Find the average value from arrays of objects
By : nanobot
Date : March 29 2020, 07:55 AM
Hope this helps This aggregation job will return average of mathematics marks throughout the collection