Expand my Community achievements bar.

Applications for the Community Advisor Program Class of 2025 are NOW OPEN – Apply Today!
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

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