Expand my Community achievements bar.

Dive in, experiment, and see how our AI Assistant Content Accelerator can transform your workflows with personalized, efficient content solutions through our newly designed playground experience.
SOLVED

Odd or even

Avatar

Level 3

Hi team,

Can any one help me how to check array count is odd or even using helper function?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Employee

You can validate it on the following lines 

{% let arrayCount = count(profile.productsInCart) %}

{%#if arrayCount % 2 = 0 %} 
    even
{%else if arrayCount % 2 = 1 %} 
    odd
{%/if%}

View solution in original post

1 Reply

Avatar

Correct answer by
Employee

You can validate it on the following lines 

{% let arrayCount = count(profile.productsInCart) %}

{%#if arrayCount % 2 = 0 %} 
    even
{%else if arrayCount % 2 = 1 %} 
    odd
{%/if%}