There are a few steps involved in this solution:

1. we take an existing array,
2. setup a new, blank array
3. Run a for loop with 3 iterations
4. On each iteration use `splice()` an array item at random using `Math.random()`
5. Push the existing members
6. Flatten the new array

Let’s discuss how this works, in detail.

After practicing all these different ways of dealing with randomness in the past week:

…it shouldn’t be too hard to solve this exercise. Let’s start with an array:

Now let’s say we want to take three random items from the above array and store them in a new array.

However, this won’t work exactly as expected, since we can have duplicates in the resulting array, such as this:

The solution is to use a technique similar to shuffling an array:

Now we’re getting an array of three arrays, each holding one member, for example:

Now, all we have to do is flatten the array:

Here’s the result of running the above code a few times:

Note:
This exercise comes from Book 3 of my book series on JS, available on Leanpub.com.