You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
358 B

4 years ago
  1. # `median()`
  2. The median method returns the median value of a given key:
  3. ```js
  4. collect([1, 3, 3, 6, 7, 8, 9]).median();
  5. // 6
  6. ```
  7. ```js
  8. collect([
  9. {
  10. foo: 1,
  11. },
  12. {
  13. foo: 1,
  14. },
  15. {
  16. foo: 2,
  17. },
  18. {
  19. foo: 4,
  20. },
  21. ]).median('foo');
  22. // 1.5
  23. ```
  24. [View source on GitHub](https://github.com/ecrmnn/collect.js/blob/master/src/methods/median.js)