Skip to content

Instantly share code, notes, and snippets.

@omegahm
Created January 9, 2015 13:51
Show Gist options
  • Save omegahm/981b96f9f70659e20a30 to your computer and use it in GitHub Desktop.
Save omegahm/981b96f9f70659e20a30 to your computer and use it in GitHub Desktop.
@sums = ko.computed =>
$.map data.sums, (value, key) =>
if @kinds().length is 0 || @kinds().indexOf(key) isnt -1
value
.reduce (a, b) ->
a + b
, 0
@omegahm
Copy link
Author

omegahm commented Jan 9, 2015

@sums = ko.computed =>
  sum = 0
  $.each data.sums, (key, value) =>
    if @kinds().length is 0 || @kinds().indexOf(key) isnt -1
      sum += value
  sum

@omegahm
Copy link
Author

omegahm commented Jan 9, 2015

@sums = ko.computed =>
  $.map data.sums, (value, key) =>
    if @kinds().length is 0 || @kinds().indexOf(key) isnt -1
      value
  .reduce ((a, b) -> a + b), 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment