Odd or even | Community
Skip to main content
Level 4
September 16, 2024
Solved

Odd or even

  • September 16, 2024
  • 1 reply
  • 383 views

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.
Best answer by Mohan_Dugganab

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
September 16, 2024

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