Adding data to an array

I’m currently using a math node to insert a value from one array to another as below.
There has to be a better way to do this esoecially since there are 24 values like this.
I tried using the array node but wasn’t successful.
I must be having a brain blockage today…

image

1 Like

Hi @Lars_Andersson,

I am currently working on an example for this and will get back to you shortly with a walkthrough. In the meantime, I would recommend checking out a couple of these resources:



Thanks!
Julia

Hi @Lars_Andersson,

I messed around with the same Nodes and was also unsuccessful. Since these Nodes are configured with payload paths, they do not accept variables and must be static references. Thus, I used a Function Node with the map() method:

The Function Node contains the following Javascript:

const combinedArray = payload.data.averages.items.map(function (item, index){
  if(payload.data.runtimes.items[index]){
    item.farr_minutes = payload.data.runtimes.items[index].farr_minutes
  }
  return item
})


payload.combinedArray = combinedArray

In this function, if there is a value for farr_minutes in the runtimes.items array, it will be combined with the payload of the averages.items array.

Thus, the combinedArray includes all of the values from averages.items, and only the farr_minutes value from the runtimes.items array.

Thanks!
Julia