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() { I1setText("nameInput", ""); I2}); I3var names = []; I4names = names + getText("nameInput"); I5appendItem(names, getText("nameInput")); I6setText("countLabel", names.length + " names"); I7Order: 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.