StoicBuilder
Later missionMission 2: A feed is a listYou can practise it now. It counts once you reach mission 2, after “First day at Ludus Labs”.Back to HQ
Exit lesson
ArraysFreeLesson 3 of 45, about 5 min
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
0 XP

The app: Chirp

ChirpHome, 2 posts

feed[0]

MMaya Okafor@mayabuilds

Shipped the notes page tonight. Fingers crossed.

0

feed[1]

TTheo Lindqvist@theoships

Asked for dark mode. Also got a font I never asked for.

0

The data behind it

feed an array of postsfeed.length 2
[ { "id": , "author": , "text": , "likes": }, { "id": , "author": , "text": , "likes": } ]
feed.js what Post and Delete run
1function addPost(text) {2 const post = { id: nextId++, author: "you", text, likes: 0 };3 feed.push(post);4}5 6function deletePost(id) {7 feed = feed.filter((post) => post.id !== id);8}

The MagisterA feed is a list, and in code a list is an array: items in order, inside square brackets. The app draws one card per item, top to bottom. Arrays count from 0, so the top card is feed[0]. Tap its text.

Step 1 of 6Tap the text of the top post
  • Tap the text of feed[0], the first item

You’re not signed in, so this lesson won’t be saved to your path. Sign in free to keep your XP.