Learn it
A list stores many items in order. Make one in Variables โ Make a List. Blocks: add [ ] to [list], item (1) of [list], length of [list], delete all of [list]. Scratch lists start at item 1.
๐งฐ Tool: free Scratch online editor (no account needed to try; a parent can create one to save projects) or the free ScratchJr app for tablets.
Code examples
Blocks (Scratch)
when green flag clicked
delete all of [jokes]
add [Why did the cookie go to the doctor? It felt crummy.] to [jokes]
add [What do you call a sleeping dinosaur? A dino-snore.] to [jokes]
add [Why are fish so smart? They live in schools.] to [jokes]
when this sprite clicked
say (item (pick random (1) to (length of [jokes])) of [jokes]) for (4) seconds
Project: Joke bot
- Make a jokes list.
- Add 5 jokes.
- Click to hear a random one.
Challenge: Ask the user for a new joke and add it with ask and wait.