n8n LabIntermediate
Find the Maximum Value in an Array in n8n
Flag the most expensive supplier quote in a list.
Live Execution Simulator
Idle
π₯
Incoming Data
βοΈ
n8n Node
π―
Next Step
> Ready. Type your expression below and click "Check Answer" to run the node.
Incoming Payload / Data:
{
"prices": [45, 120, 80]
}
βοΈ Your expression is executed against test data β any correct solution passes. +20 XP
β Solution & explanation
Math.max(...$json.prices)
Output: 120
Math.max() takes individual numbers, not an array. The spread operator ... unpacks the array into separate arguments. n8n also provides $json.prices.max().π‘ Pro tip: Math.max($json.prices) without the spread returns NaN β a frequent mistake.
Also accepted: $json.prices.max()