Skip to main content
Level 4
Sep 16, 2024 3:42 PM UTC
Solved

Odd or even

Hi team,

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Mohan_Dugganab
Mohan_DugganabAccepted solution
Adobe Employee
Sep 16, 2024 6:35 PM UTC

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

1 reply

Mohan_Dugganab
Adobe Employee
Mohan_DugganabAdobe EmployeeAccepted solution
Adobe Employee
Sep 16, 2024 6:35 PM UTC

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