JavaScript nested methods in a class
I am coding a JS class which holds a price
number and a ratings
array of numbers. I have already written a getAverageRating
method that returns the average of the numbers in ratings
, and am now trying to code a valueMeter
method that takes the average of every value in ratings
, divides it by the price
, and multiplies it by a hundred (no comment on the relevancy of such a method). Rather than re-writing the code to calculate the average, I am trying to use my getAverageRating
method.