Too Close to the Sun explainer

The aim of this puzzle: Print out the 4th start in the list.

Walkthrough of the solution: The stars variable is storing an array of strings. There are 5 strings, and the 4th one is 'Wolf 359'. The elements of an array are counted from beginning to end starting with 0 instead of 1. The number of each item is called the index, so 'Sun' is at index 0, 'Alpha Centauri' is at index 1, 'Barnards Star' is at index 2, and 'Wolf 359' is at index 3.

To get an element from an array, you use the index inside of square brackets []. To get the element at index 3 from the stars array, you use stars[3]. You can double tap the 0 and then change it to a 3 to solve this puzzle.

Sample code solution:
(Tap below to reveal)

var stars = [
  'Alpha Centauri',
  'Barnards Star',
  'Wolf 359',
  'Lalande 21185'


JavaScript Concepts: Calling Functions, Data Structures (array), Identifiers, Indexing

Grasshopper Concepts: print()

1 Like