We do our best to ensure that the code in these articles works as advertised, but please be aware that Zapier Support does not officially help with code steps due to their advanced nature. Feel free to comment on the article or ask in the Zapier Community, where we have code-savvy folks (including the author of this post).
If you’ve ever needed to count the number of items in an array and weren’t quite sure how to do it, the solution lies with Code by Zapier. And it’s easy to do!
The Setup
COPY THE CODE
let Set = inputData.Set;
let SetCount = 0; // defaults the Set Count to 0
// If Set exists
if (Set) {
Set = Set.split(","); // creates array by splitting Input Data Variable at commas
SetCount = Set.length; // determines the length of the array (aka number of array items)
}
output = /{SetCount, Set}];
The Results
Contribution by Troy Tessalone
Troy is a Certified Zapier Expert who automates workflows with no-code and low-code apps to help clients save time and make money.