I have an array of clothing sizes, which I need to divide into two array, where one will have a numbers and other one letters (numberSize and letterSize arrays), then I need to compare both of them to a given variable, and if there is a match, then get the forloop.index0 and show the same index variable from the main array availableSizes
And, well, I am stuck. The first and last filters don`t work the way I thought they would and I end up with 6 - 5XL if you print out {{ numberSize)) - {{ letterSize }}.
I also tried to iterate through availableSizes with cycle to assign number / letter, but couldn`t figure out how to re assign these values to a separate arrays
Hope you can help to figure this out
{%- assign availableSizes = '6 - XXS, 8 - XS, 10 - S, 12 - M, 14 - L, 16 - XL, 18 - XXL, 20 - XXL, 22 - 3XL, 24 - 4XL, 26 - 5XL' | split: ', ' -%}
{%- assign currentSize = 10 -%}
{%- assign numberSize = availableSizes | split: ' - ' | first -%}
{%- assign letterSize = availableSizes | split: ' - ' | last -%}
{%- for potentialNumberSize in numberSize -%}
{%- if currentSize == potentialNumberSize -%}
{%- capture currentIndex %} {{ forloop.index0 }} {% endcapture %}
{%- endif -%}
{%- endfor -%}
{%- for potentialLetterSize in letterSize -%}
{%- if currentSize == potentialLetterSize -%}
{%- capture currentIndex %} {{ forloop.index0 }} {% endcapture %}
{%- endif -%}
{%- endfor -%}
["{{availableSizes[currentIndex]}}"]
// also tried this
// ["{% for potentialNumberSize in numberSize offset: currentIndex -%}{{- potentialNumberSize }}{% endfor %} - {% for potentialLetterSize in letterSize offset: currentIndex -%}{{- potentialLetterSize }}{% endfor %}"]
// and this
// ["{% for potentialNumberSize in numberSize[currentIndex] -%}{{- potentialNumberSize }}{% endfor %} - {% for potentialLetterSize in letterSize[currentIndex] -%}{{- potentialLetterSize }}{% endfor %}"]