​ How to use JavaScript Code to find an Item at the same Index Position across Arrays ↔️

  • 21 March 2022
  • 0 replies
  • 296 views
​ How to use JavaScript Code to find an Item at the same Index Position across Arrays ↔️
Userlevel 7
Badge +14

📌  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 users.

The Purpose

Allows for finding a value at the same index position across arrays, which is useful if you have multiple lists.

An Example

A1 | A2
A | X
B | Y
C | Z

How to Configure

 

Copy the Code

var A1 = inputData.A1.trim().split(','); // Array1
var A2 = inputData.A2.trim().split(','); // Array2
var Find = inputData.Find; // Find this value in Array1
var Index = A1.indexOf(Find); // Finds value in Array 1
var Lookup = A2[Index]; // Finds matching value at same index position in Array 2

output = [{Index, Find, Lookup, A1, A2}];

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.


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.