Odd or even | Community
Skip to main content
New Participant
September 16, 2024
Solved

Odd or even

  • September 16, 2024
  • 1 reply
  • 381 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
Mohan_DugganabAccepted solution
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%}