Hi,
I’m trying to find the best way of creating a new array containing only items from the original array that actually had a value.
[
{
"array": [
{
"value": "Heat Different"
},
{
"value": "Europa Way"
},
{
"value": ""
},
{
"value": "Norwich"
},
{
"value": "Norfolk"
}
],
"__IMTAGGLENGTH__": 5
}
]
Thanks in advance for the help.
Hello @Alan_Heat,
Probably the most straightforward way to do this is a combination of map() and remove() function on that array.
Result:
map() will pull the value from each collection where the key is “value” and put them into a simple array. This array includes the element without any value.
remove() will remove any elements that have no value, leaving you with the result above.
Hope that helps!
3 Likes
Bingo! @Alan_Heat I cover this very example in Part 8 of my Make for Make Newbies video series. You’ll find a ton of useful examples on array mangement and general data structure management throughout that series. I recommend it, if I do say so myself
I use the {{null}} operator instead of {{emptystring}} but I am not sure it matters either way when array values are concerned.
2 Likes
Hi @alex.newpath,
Thanks for this, i’ll check it out.
1 Like