Random List Access Pattern

Name Code (Block) Code (Text)
Random List Access Pattern

How does it work?

Many App Lab projects run in the following way.

  1. The user is interested in seeing items in a list, like a list of favorite foods, or a list of reminders.
  2. The app shows the user one item in the list at a time.
  3. By clicking buttons (or otherwise interacting with the app) the a new random item in the list is shown to the user.

This pattern allows a user to see random elements in a list. In order to make it work, create an index variable and a list. Then generate a random number between 0 and the length of the list minus one and set the index to that value. Then update the screen.

Found a bug in the documentation? Let us know at documentation@code.org