How Many? explainer


Aim of the puzzle: Use the .length property to get the number of items in an array.

Walk through of solution: The starting code prints all the contents the imported array. That’s not the best way to count elements.

Tap listOfDestinations inside the console.log(). Then, with listOfDestinations highlighted, tap the .length button. Now, the console.log() can access the number of items in the array, rather than the contents.

Sample code solution:
(Tap below to reveal)

import { listOfDestinations } from '';

let numberOfDestinations = listOfDestinations.length;

console.log('There are ' + numberOfDestinations + ' to choose from.');

Javascript Concepts: Variables, Console, .length, import

Grasshopper Concepts: