Hey guys! Excited to be learning the ropes here. I’m building a web app and I am a little unsure of the best way to achieve the following:
The user clicks ‘Complete’ on a challenge which is returned from an API into a data variable ActiveUserChallenges
The click triggers logic to sent a put request to my API, setting that challenge’s ‘active’ value to 0
Now, I also need to generate a new challenge for the user. I call my API and return a list of possible challenges into another variable, UserChallengesByInterest
However, I can’t work out how I can now select one item from the array UserChallengesByInterest at random (something like a formula to just pick one item) and then return the id so I can trigger another put on my API to set the new challenge’s active value to 1.
Thanks for any advice, and sorry if the answer is staring me in the face.