How can I separate array items with a comma in a custom blog article template?

I am making a custom blog article template.

I want to display a list of categories depending on the TAGS section in the articles admin page .

How do I display this array with a comma separating each item (though not the last item)?

{% assign categories = “Emolient,Texture Enhancer,Plant Extract,Humectant,Emulsifier,Antimicrobial,PH Adjuster,Chelating Agent,Antioxidant,pH Adjuster,Solvent” | split: ‘,’ %}

Category: {% for tag in article.tags %} {% for cat_tag in categories %} {% if cat_tag == tag %} {{cat_tag}}

{% comment %}
I want a comma to separate each item, but not the last item
{% endcomment %}
{% endif %}
{% endfor %}
{% endfor %}

Hi @Arthur_I_A ,

Please change all code:

{% assign categories = "Emolient,Texture Enhancer,Plant Extract,Humectant,Emulsifier,Antimicrobial,PH Adjuster,Chelating Agent,Antioxidant,pH Adjuster,Solvent" | split: ',' %}

Category:
{% assign check = 0 %}
{% for tag in article.tags %}
  {% for cat_tag in categories %}
    {% if cat_tag == tag %}
      {% unless check == 0 %},{% endunless %}{{cat_tag}}
      {% assign check = 1 %}
      {% comment %}
      I want a comma to separate each item, but not the last item
      {% endcomment %}
    {% endif %}
  {% endfor %}
{% endfor %}

Hope it helps!

A sweet and simple solution! Many thanks !