All puzzles
Per page
I
List · appendItem · length

Add a name

Each click on the addButton button adds the name in the nameInput text box to the names list. Then it empties the text box. Last, it shows the number of names in the countLabel label.

After someone adds Ana and then Ben, the label shows 2 names.

7 strips: I1 to I7

onEvent("addButton", "click", function() {
I1
setText("nameInput", "");
I2
});
I3
var names = [];
I4
names = names + getText("nameInput");
I5
appendItem(names, getText("nameInput"));
I6
setText("countLabel", names.length + " names");
I7

Answer key: I. Add a name

Order: I4, I1, I6, I2, I7, I3. Extra: I5

Lines with the same mark can go in either order.

var names = [];
onEvent("addButton", "click", function() {
	appendItem(names, getText("nameInput"));
	setText("nameInput", "");
	setText("countLabel", names.length + " names");
});

Extra strip: names = names + getText("nameInput");. + joins the list and the name into one String, so names is no longer a list. appendItem() adds an item to a list.