I'm building a quiz app for a school project, and I want to pull 3 unique, random elements from an array of possible answers. However, I want the 0th index to be excluded, as this is the correct answer and will always be added separately.
const answers = ["Answer 1", "Answer 2", "Answer 3", "Answer 4", "Answer 5", "Answer 7"]
I'm extremely new to JS and have spent some time looking into a way to handle this. Apologies in advance if it's an accessible solution, I might not be wording my question well.
https://stackoverflow.com/questions/65386313/js-how-can-i-randomly-pull-3-unique-elements-from-an-array-except-for-the-0th December 21, 2020 at 08:55AM
没有评论:
发表评论