Count() in Lambda?
![Erin](https://us.v-cdn.net/6037124/uploads/userpics/0K8NT74W8WD8/nYA4TPTOVADTB.jpeg)
I have an array of objects that have their own little arrays:
[
{"numbers":[[1],[1,2],[1,2,3]]},
{"numbers":[[4],[4,5],[4,5,6]]}
]
I want to update the objects to include only child arrays with with more than one element so the result would be:
[
{"numbers":[[1,2],[1,2,3]]},
{"numbers":[[4,5],[4,5,6]]}
]
My research says that in Javascript, this is accomplished using count(). So it would look something like:
return $this.numbers.count() >1
But when I run that, it thinks "count" is a field within "numbers".
How do I write the Javascript in Xano's Lambda to count elements within an array?
Thanks!
Comments
-
Hey @Erin , neat problem! I made a short video to show you how to accomplish this goal with a lambda as well as with the nocode stack: https://share.descript.com/view/oUo2RABfvjU
This is the kind of hard problem we work on during our daily State Change Pro office hours.
-
@Ray Deck Thank you so much for that fantastically detailed response! I had hoped that Lambdas had some magical way of processing arrays that was more efficient than loops. But now I know, so I went the no-code loop route for my situation.
Really appreciate the generous answer, and kudos on such a valuable business model.
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback