Sun Spotter explainer

The aim of this puzzle: Print a different message depending on whether the value is 'sun' or 'moon'.

Walkthrough of the solution: The value variable stores a string picked at random from the array. It will either hold 'sun' or 'moon'. The value gets printed out and then it’s time to print the message.

But first, we need to know which string the value is storing, so we use an if statement and check if the value is equal to 'moon'. If it is, then we print 'It is nighttime.'.

Now we need to add another check for when value is 'sun', so after the first if statement is over, we add another if statement that checks if value is equal to 'moon'.

In the block of that new if statement we add a print() call and a string that says, 'It is daytime'.

Sample code solution:
(Tap below to reveal)

var value = pickRandom(['sun', 'moon']);

if (value === 'moon') {
  print('It is nighttime.');

if (value === 'sun') {
  print('It is daytime');

JavaScript Concepts: Binary Expression (===), Calling Functions, Conditionals (if statement), Data Structures (Arrays), Identifiers, Variable Declaration
Grasshopper Concepts: pickRandom(), print()