Each click on the nextButton button shows the next word of the words list in the wordLabel label. Once the label shows the last word, more clicks keep it on the last word.
After 5 clicks, the label shows fox.
10 strips: H1 to H10
setText("wordLabel", words[index]); H1var words = ["cat", "dog", "fox"]; H2if (index > words.length) { H3onEvent("nextButton", "click", function() { H4} H5}); H6if (index > words.length - 1) { H7index = index + 1; H8index = words.length - 1; H9var index = 0; H10Order: H2, H10, H4, H8, H7, H9, H5, H1, H6. Extra: H3
Lines with the same mark can go in either order.
var words = ["cat", "dog", "fox"];
var index = 0;
onEvent("nextButton", "click", function() {
index = index + 1;
if (index > words.length - 1) {
index = words.length - 1;
}
setText("wordLabel", words[index]);
}); Extra strip: if (index > words.length) {. The index of the last item is words.length - 1, which is 2. With > words.length, index can reach 3, and words[3] is undefined.