Is there an easy way or shorthand in a Toddle formula to take every object in an array and just add an additional value/property to each one while retaining all the existing values? I asked the Toddle AI and it mentioned using the Map function and ...item to spread the properties but I don't understand what this means exactly or how to do so in a Formula.
Does this just mean mapping each item to a new object and having to re-define the key/value pairs for every property again like I did in the attached screenshot? This isn't a huge deal on a smaller object with only a couple properties per element, but when there are many values that all need to be mapped to the same thing again it feels very tedious.
For example, I have an array of exercises in my workout program and I want to go through every exercise in the array and add a tag property (where there's some formula to calculate the tag value).
So if my exercise array is like:
[
{
"muscleGroup": "Chest",
"ID": 1,
"exercise": "Bench Press, Barbell"
},
{
"muscleGroup": "Front & Side Delts",
"ID": 2,
"exercise": "Lateral Raise, Dumbbell"
},
{
"muscleGroup": "Chest",
"ID": 1,
"exercise": "Bench Press, Dumbbell"
}
]
I'd like the output to be:
[
{
"muscleGroup": "Chest",
"ID": 1,
"exercise": "Bench Press, Barbell",
"tag": 0
},
{
"muscleGroup": "Front & Side Delts",
"ID": 2,
"exercise": "Lateral Raise, Dumbbell",
"tag": 0
},
{
"muscleGroup": "Chest",
"ID": 1,
"exercise": "Bench Press, Dumbbell",
"tag": 1
}
]
So I keep all the original properties and values and just add a tag to each element.