0

Given an array of { name: string; amount: float }, how does one write out the data running total.

{% for entry in my_array %}
   {{ entry.name }}, {{ entry.amount }}, {{ ???running total??? }}
{% endfor %}
4

1 回答 1

2

这是你要找的吗?

{% assign running_total = 0 %}
{% for entry in my_array %}
  {% assign running_total = running_total | plus: entry.amount %}
{% endfor %}
于 2016-09-13T15:52:35.963 回答