Personal notes on making things Programming ✳ Technology ✳ Life
Back to the notebook
Demonstrations / LESSON 1 MIN READ

Demonstration: 2. Make the idea concrete

Represent the reading list with a small JavaScript example you can inspect and copy.

Make the idea concrete
THE IDEA, THEN THE DETAILS
In this piece

This is lesson two of the demonstration course. We are turning a reading-list question into data. The sample below runs in a browser console and does not need an account or a service.

Keep only the useful details

An object groups the details of one article. A list of objects lets us ask the same question about every article. We use minutes as a number and read as a boolean so the conditions stay explicit.

Filter the reading list

The filter keeps articles that are unread and take ten minutes or less. Copy the example, run it in your browser console, and inspect the returned list. Only “A useful question” should remain.

reading-list.js
const articles = [n  { title: 'A useful question', minutes: 8, read: false },n  { title: 'A longer exploration', minutes: 18, read: false },n  { title: 'A familiar idea', minutes: 5, read: true },n];nnconst nextReads = articles.filter(article =>n  !article.read && article.minutes <= 10n);nconsole.log(nextReads);
END OF LESSON

YOUR READING LIST

Saved for later.

Saved in this browser only.