This message was deleted.
# help
s
This message was deleted.
f
It increases the running count by one whenever an item has "goal" as its property value for "a".
a
Great, thank you. What about the use case? Does this mean we only need to know how many “goal” items exist? I ask because my mind tells me, if that’s the case, then there should be a better way to do that.
f
The use case is to track how a count develops over a series of data items, e.g. to graph it or to perform calculations on it.
a
I see. So is it correct to assume that the result
[0, 0, 1, 1, 1]
is not sufficient in itself?
f
Sufficient for what?
a
Oversight. I understand what you meant with your penultimate reply better now.
m
It may be interesting to understand why this works too.
d3.cumsum
adds numbers up and keeps track of the running total. When you add things that aren't numbers, JS does it's best.
true + false
is equal to 1, and
true + true
is equal to 2. JS implicitly converts things it tries to add to numbers (sometimes...), and when it does that with true and false it gets 1 and 0, respectively
a
Great. I understand how it works and its potential application better now. Thank you 😊