Hello everyone,
I’m currently failing to select two random items from an array.
I select a random item like this:
{{get(2.customArray; floor(random * length(2.customArray)) + 1)}}
What is the right approach now?Delete the selected item from the array and pick a new one? How would i do that?
thanks for your help!
Hi Sebastian,
you can use shuffle() on the array and then on the next step use first() and last() to get two different random items.
Or, in the first step you can create two different random numbers and then use get() with them for two different items from the array.
Welcome to the Make community!
You can use the built-in function slice
to return a new array with a fixed number of elements from the original array.
e.g.:
{{ slice(shuffle(2.customArray); 0; 2) }}
For more information, see the slice function documentation in the Help Center.
Hope this helps! Let me know if there are any further questions or issues.
— @samliew
1 Like
Very good solutions and much easier than I thought. With the second one I also have a solution for more than two random picks .
I’m immediately motivated to do more :)) Thank you very much!
1 Like
No problem, glad I could help!
1. If anyone has a new question in the future, please start a new thread. This makes it easier for others with the same problem to search for the answers to specific questions, and you are more likely to receive help since newer questions are monitored closely.
2. The Make Community guidelines encourages users to try to mark helpful replies as solutions to help keep the Community organized.
This marks the topic as solved, so that:
- others can save time when catching up with the latest activity here, and
- allows others to quickly jump to the solution if they come across the same problem
To do this, simply click the checkbox at the bottom of the post that answers your question:
3. Don’t forget to like and bookmark this topic so you can get back to it easily in future!
Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —
Getting Started
Help Centre Basics
Articles & Videos
Partner & Custom Apps
Hope this helps! Let me know if there are any further questions or issues.
— @samliew