consta = [1,2,3,4] // default behavior: avgOfArray(a,"") // => 2.5 // if no data present at the path the default value is used: avgOfArray(a,"a",1) // => 1
consta = [{value:1},{value:2},{value:3},{value:4}] // default behavior: avgOfArray(a,"value") // => 2.5 // if no data present at the path the default value is used: avgOfArray(a,"a",1) // => 1
Author
M.Karkowski
Export
Returns
{number}
Parameters
arr: any[]
The array
path: string
The path to the data.
OptionaldefaultValue: number = 0
if no data present at the path the default value is used.
Helper to determine the average of an array
Example 1:
Example 2:
Author
M.Karkowski
Export
Returns
{number}