Coffee Run explainer


#1

The aim of this puzzle: Add more names, and randomly pick who will pay for coffee.

Walkthrough of the solution: The person variable is assigned to an array inside a pickRandom() function. This means the person variable will store one name, randomly selected from the array each time the code runs. The code starts with only two names, and the solution expects at least 4 names.

Tap below the last name in the array, then tap the str key to bring up the qwerty keyboard. Then enter any name you like. Repeat this at least once so that the array has a minimum of 4 names.

Sample code solution:
(Tap below to reveal)

var person = pickRandom([
    'John',
    'Jessica', 
    'Jamar',
    'Jasmine', 
    'Jia'
]);
print(person + ' will buy the coffee');

JavaScript Concepts: Calling Functions, Data Structures (Arrays), Identifiers, Variable Declaration, Strings
Grasshopper Concepts: pickRandom(), print()