making a list, checking it once

Checking a list is called traversal (actually, going through the list and doing anything to it is).  Here’s an example of a list and a traversal of it.  These are the Great Lakes of North America.

The script variable is a variable that does not belong to any sprite and is used only in the script.  This code only says the names of the Great Lakes, but if you take out that purple block and put something else in there, you could do other things.  For example, if you wanted to see which lake had the longest name, you could have a script variable called longest and store the first name there. Then, instead of saying the name, you could have an if block that checks if the current name is longer than the longest  name and if it is, make that name the longest name..  Then put your purple say block at the end and say longest for 2 secs.

Leave a Reply

Your email address will not be published. Required fields are marked *