A Dash of Random explainer

The aim of this puzzle: Draw two boxes with colors that are randomly generated.
Walkthrough of the solution: pickRandom() randomly selects a value from a list, while color holds a list of different colors. pickRandom(color) will randomly select one color, such as blue or purple. To make a box have a random color, pickRandom(color) needs to go inside drawBox(), like drawBox(pickRandom(color)). This is called Call Nesting; when a function — pickRandom() — is put inside another function — drawBox(). The function pickRandom(color) runs and a color is selected, this color is then “given” to the drawBox() function. If, for example, the random color selected was red, the computer would “see” drawBox(red) rather than drawBoxes(pickRandom(color)). This means a red box would be drawn.
Sample code solution:
(Tap below to reveal)


JavaScript Concepts: Calling Functions, Call Nesting, Identifiers
Grasshopper Concepts: pickRandom(), drawBox()


I was a little confused by this one at first, but I assume this is happening:

var color = ['red', 'green', 'orange', 'yellow'];
function pickRandom(arr) {
  var index = Math.floor(Math.random() * arr.length);
  return arr[index];

The instructions say “add a second box of random color”, the solution then displays 2 boxes initially. The solution is actually to add a third box. Would it not be better to rephrase the question to: “add another box of random color”?Screenshot_20180421-153928


Thanks for the feedback!

You can also solve this puzzle by replacing the non-random colored box, with a drawBox(pickRandom(color)). But really appreciate your feedback on the wording, we’re looking at adjusting the instructions slightly for this puzzle.

H :slight_smile:


Thanks very much, I didn’t consider that perspective as well.

1 Like

Oh God please make this stop. I was learning pretty good til I got here, Dash of Random. I swear I am doing exactly what it says and it’s like a frustrating circle of hell. It’s in a loop telling me I’m wrong but the explanation is harder than the question. I really want to continue with the course but I’m jammed up here.
Thanks for any help.
Why do I get two error messages that seem to contradict each other (red box mssg vs blue box mssg)? Do I add a color to Random Color or not?

Problem solved.
16-yr old stepsons said erase every thing that was there (the long line of code) and type in what I wanted.


This question is stuck. When filling out the code and pressing play, nothing happens. Doesn’t say if it’s right or wrong. There seems to be no way to advance past this question because of this bug.


Yep …still stuck …I contacted them and am waiting to hear back…shame because I was actually learning but now am frustrated and feeling stupid…thanks I guess you get what you pay for…

1 Like

So I did this and it won’t let me press the play button to continue


Hi @Curtis_Frierson, @Fred_Duffer and @Gavin_Gallagher,

Thanks so much for flagging this issue. There was a small bug on the puzzle, which we’ve now fixed. If you connect to wifi, then hard-close and re-open the app the issue should be resolved.

H :slight_smile:

Thank you for the very quick response

Shouldn’t we define the array first?
Why does b=blue and o=orange? Certainly there’s some background coding going on.

When we pick random, why must it be confined to colors? Instead of the colour of the box, why can’t we pick random the shape of the box for instance?

Perhaps we can learn to define and limit the options via coding before we learn pickrandom function.

If we use the code playground it would not work because we have not define the parameters.

I have never learnt coding before and it would be a great help if the developers take into account this feedback as it does not seem logical for a beginner.

1 Like

I’m getting the same thing.

I don’t think that’s how it works: it makes perfect sense, but it doesn’t allow pickRandom(pickRandom(color)).

pickRandom(pickRandom(color)) is allowed, but pickRandom(orange) is not, and that’s quite confusing.
It doesn’t typecheck for me, basically, at least not with the wording on the screenshot.

Hey there, neither pickRandom(pickRandom(color))) nor pickRandom(pickRandom(orange))) will work.

The pickRandom() function takes an array, and returns a single random item from that array.

color is an array that looks something like:

['red', 'orange', 'blue', 'green'];

pickRandom(color) chooses and returns a single string from that array. If you have 2 pickRandom() functions like: pickRandom(pickRandom(color))), the outer one won’t work, because its argument is not an array.

Hope this helps! Let me know if you have any questions.

1 Like

Rrright, in theory there is no difference between theory and practice. But in practice, I tried pickRandom(pickRandom(color)) – and it worked.
At that point I realized I don’t actually know how to works :slight_smile:
Please enjoy the screenshot of it working:

Hey there,

It looks like the puzzle’s completion logic might be allowing it as a solution, but that doesn’t mean that the code is working.

You can tell it’s not working by the fact that no box is being drawn on the console, because drawBox() doesn’t know what to do with pickRandom(pickRandom(color))

Trying to run the same code on my end, the completion trigger is not allowing it as a solution, so my guess is that you might be on an old version of the app that has a different version of this puzzle.

Try updating the app, and you should get the proper error message.

If you update the app and its still completing, please submit a bug report by tapping on the menu button in the top right of the puzzle screen and selecting “Send Feedback” ==> “Report a Problem”


I’m using the latest 2.17.0 version that’s publicly available. I reported a problem as suggested.

The simple way to solve the dashboard puzzle -

The user is asked to update the second “Red” colour to a random colour hence keep the Drawbox and only update the function to pick random. Note " please do not select any colour like red or orange " Select the option colour as a standard function.
drawbox (pickRandom (colour);