top of page

How to Code a PB&J

Click on any image to enlarge, scroll through images.

The Project: Offline coding exercise in which students collectively "code" a peanut butter and jelly sandwich, using the vocabulary and process found in the book, How to Code a Sand Castle.

​

I use a whiteboard, and ask students to tell me the steps exactly as I should do them. Invariably, they will tell me to put the peanut butter and jelly on the bread, without telling me to open the lids and use a spoon or knife to put the PB&J on the bread. With numerous mis-steps, we get through the process. Throughout the exercise, I use the terms code and sequence.

​

Then I ask for variables, such as substituting almond butter or cream cheese for peanut butter, or Nutella for jelly. We incorporate the variable with an IF-THEN-ELSE statement.

​

Finally, I ask them if there is any part that can be use a loop, and they usually figure out that they can loop to make additional sandwiches.

​

I've used this with students as young as first grade and up through 6th grade.

​

bottom of page