Expand my Community achievements bar.

Join us on September 25th for a must-attend webinar featuring Adobe Experience Maker winner Anish Raul. Discover how leading enterprises are adopting AI into their workflows securely, responsibly, and at scale.
SOLVED

Odd or even

Avatar

Level 4

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 Advisor

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 Advisor

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%}