How to use a message variable to navigate an array that is also a message variable, in a change node?

Hey there,

I'm struggling trying to use a message variable to navigate an array that is also a message variable, in a change node, as follows:

image

I tried the following, but nothing works:
msg.months[msg.index]
msg.months[index]
msg.months[$.index]
msg.months[$$.index]

What am I doing wrong?

Ah!

Just got it working by using twice the $$ as follows:

$$.months[$$.index]

image

There is no need for JSONata in simple cases like this, you can use array syntax...

image

(requires newish version of node-red)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.