{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/immutable-js/issues/636","labels_url":"https://api.github.com/repos/facebook/immutable-js/issues/636/labels{/name}","comments_url":"https://api.github.com/repos/facebook/immutable-js/issues/636/comments","events_url":"https://api.github.com/repos/facebook/immutable-js/issues/636/events","html_url":"https://github.com/facebook/immutable-js/issues/636","id":108498568,"number":636,"title":"Best way to accomplish sum()?","user":{"login":"Anahkiasen","id":1321596,"avatar_url":"https://avatars.githubusercontent.com/u/1321596?v=3","gravatar_id":"","url":"https://api.github.com/users/Anahkiasen","html_url":"https://github.com/Anahkiasen","followers_url":"https://api.github.com/users/Anahkiasen/followers","following_url":"https://api.github.com/users/Anahkiasen/following{/other_user}","gists_url":"https://api.github.com/users/Anahkiasen/gists{/gist_id}","starred_url":"https://api.github.com/users/Anahkiasen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Anahkiasen/subscriptions","organizations_url":"https://api.github.com/users/Anahkiasen/orgs","repos_url":"https://api.github.com/users/Anahkiasen/repos","events_url":"https://api.github.com/users/Anahkiasen/events{/privacy}","received_events_url":"https://api.github.com/users/Anahkiasen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-26T22:05:30Z","updated_at":"2015-09-27T15:35:19Z","closed_at":null,"body":"I'm transitioning my codebase from custom objects + Lodash and so far Immutable has replaced both perfectly. But there's ont thing I can't seem to do easily which is to get the sum of a List/Map. Currently doing this:\r\n\r\n```js\r\nlet total = 0;\r\nentries.forEach(entry => total += entry.get('price'));\r\n```\r\n\r\nIs there anything similar to Lodash's `sum` like `entries.sum('price')` or `entries.sum(entry => entry.get('price'))` or something that I missed in the documentation? "},"comment":{"url":"https://api.github.com/repos/facebook/immutable-js/issues/comments/143568240","html_url":"https://github.com/facebook/immutable-js/issues/636#issuecomment-143568240","issue_url":"https://api.github.com/repos/facebook/immutable-js/issues/636","id":143568240,"user":{"login":"edvinerikson","id":3890572,"avatar_url":"https://avatars.githubusercontent.com/u/3890572?v=3","gravatar_id":"","url":"https://api.github.com/users/edvinerikson","html_url":"https://github.com/edvinerikson","followers_url":"https://api.github.com/users/edvinerikson/followers","following_url":"https://api.github.com/users/edvinerikson/following{/other_user}","gists_url":"https://api.github.com/users/edvinerikson/gists{/gist_id}","starred_url":"https://api.github.com/users/edvinerikson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edvinerikson/subscriptions","organizations_url":"https://api.github.com/users/edvinerikson/orgs","repos_url":"https://api.github.com/users/edvinerikson/repos","events_url":"https://api.github.com/users/edvinerikson/events{/privacy}","received_events_url":"https://api.github.com/users/edvinerikson/received_events","type":"User","site_admin":false},"created_at":"2015-09-27T15:35:19Z","updated_at":"2015-09-27T15:35:19Z","body":"I couldn't find any methods like `sum` but I guess the closest way to accomplish something like `sum` is to use the `reduce` method.\r\n\r\n```js\r\nvar entries = Immutable.fromJS([\r\n    {price: 1},\r\n\t{price: 2},\r\n    {price: 3},\r\n]);\r\n\r\nvar sum = entries.map(entry => entry.get('price')).reduce((prev, current) => prev + current);\r\nconsole.log(sum); // 6\r\n```"}}