Lists (Arrays) and objects
Store many values in one variable and go through them with "for each".
Variables store anything
A variable can store a number, a text, yes/no, a list or an object. Use set variable to with the list with block (Arrays category). The block + and − buttons change the number of items.
Read and change
- item 1 of list: the first item is 1; -1 is the last.
- add … to the end of list, insert, replace, delete and sort change the list stored in the variable.
- length, position of, contains: questions about the list.
Loops (Control category)
- for each item in list: repeats once per item.
- for each item with index: also gives the position (1, 2, 3…). Great for two parallel lists (names and points).
- for each key and value in object: goes through an object.
- break out of loop and skip to next loop work in every loop.
Advanced
- for each item of list compute (map), items where (filter), first item where, accumulate (reduce). Inside them, use the item block.
- sum/average/highest/lowest of the items, sort, shuffle, remove duplicates, join with.
- Tables: table with 3 rows and 3 columns and item row … column ….
The variable box on the stage shows the whole list, numbered.