Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Vazul Hites
PLUS
Vazul Hites
Courses Plus Student 876 Points

How to randomly pick an item in array , and then exclude that random value until it has chosen all values in array?

I am trying to randomly sift through an array of Strings, and have it select values at random, and then exclude that value the next time it randomly go through the process again, eventually ending with only one value left in the array.

1 Answer

Bryant Feld
seal-mask
.a{fill-rule:evenodd;}techdegree
Bryant Feld
Full Stack JavaScript Techdegree Student 26,144 Points

set up an empty array - make a random choice - remove the random choice from the target array - and add it to the empty array;

post your code if you need more help