# Beginner \[Exercise 6: Iterations\] (Training slides exercise)

**URL:** <https://community.silverfin.com/t/beginner-exercise-6-iterations-training-slides-exercise/1738>\
**Category:** Exercises\
**Tags:** loop, tables, exercises, training, beginner\
**Created:** [April 7, 2020, 10:29am UTC](https://community.silverfin.com/t/beginner-exercise-6-iterations-training-slides-exercise/1738 "2020-04-07T10:29:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![borjaGonzalez](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/borjagonzalez/32/825_2.png) [@borjaGonzalez](https://community.silverfin.com/u/borjaGonzalez)\
**Post date:** [April 7, 2020, 10:29am UTC](https://community.silverfin.com/t/beginner-exercise-6-iterations-training-slides-exercise/1738/1 "2020-04-07T10:29:00Z")

</div>

Create a table with 4 columns (it doesn’t matter which layout you use). Within that table create a fori loop to input the below data related to the company’s investments. The category field should have 3 options: computers, vehicles and phones. (tip: the fori loop should go after the header and layout definition of the table)  
_Bonus question_: input some data in the table you have just created and below the table, print the name and value of the items with the category “computers”  
The final output should look like this:

**![|653px;x221px;](https://lh6.googleusercontent.com/Z1oApLJ01IftAXwHOMXoGb7574m-GzmRYzGPIKisqmOJebL9-uj9leRCwG0_rL_AcnkbjbGQR-HtSyyFEvP02kRpWcxX_7vpomRg2TAK30dT383sNwnxtsbO8jHVGuCAjORmgbVhndD3iUUAZ2OIccSG=s2048)**

---

<div class="post-metadata">

**Author:** ![borjaGonzalez](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/borjagonzalez/32/825_2.png) [@borjaGonzalez](https://community.silverfin.com/u/borjaGonzalez)\
**Post date:** [April 7, 2020, 12:26pm UTC](https://community.silverfin.com/t/beginner-exercise-6-iterations-training-slides-exercise/1738/2 "2020-04-07T12:26:36Z")

</div>

Solution:

```auto
{% stripnewlines %}
| Name
| Asset category
| Disposed?
| Value (£)
{% newline %}
|--------
|--------
|--------
|--------#+
{% newline %}
{% fori item in custom.investments %}
|{% input item.name %}
|{% input item.category as:select options:'computers|vehicles|phones' %}
|{% input item.disposed as:boolean %}
|{% input item.value as:currency %}
{% newline %}
{% endfori %}
{% endstripnewlines %}

{% for item in custom.investments %}
  {% if item.category == 'computers' %}
    {{ item.name }} = {{ item.value | currency }} 
  {% endif %}
{% endfor %}

```

Solution using HTML Tables:

```auto
<table class="usr-width-100 usr-bordered">
  <thead>
    <tr>
      <th class="">Name</th>
      <th class="">Asset category</th>
      <th class="">Disposed?</th>
      <th class="">Value (£)</th>
    </tr>
  </thead>
  <tbody>
    {% fori item in custom.investments %}
      <tr>
        <td class="">{% input item.name %}</td>
        <td class="">{% input item.category as:select options:'computers|vehicles|phones' %}</td>
        <td class="">{% input item.disposed as:boolean %}</td>
        <td class="">{% input item.value as:currency %}</td>
      </tr>
    {% endfori %}
  </tbody>
</table>

{% for item in custom.investments %}
  {% if item.category == 'computers' %}
    {{ item.name }} = {{ item.value | currency }} 
  {% endif %}
{% endfor %}

```
