When someone clicks the cheapButton button, make a new cheap list with every price in the prices list that is under 10. Show the cheap list in the cheapLabel label.
The label shows 4.5,7.25,9.
11 strips: L1 to L11
onEvent("cheapButton", "click", function() { L1appendItem(cheap, i); L2}); L3setText("cheapLabel", cheap); L4var cheap = []; L5} L6if (prices[i] < 10) { L7for (var i = 0; i < prices.length; i++) { L8appendItem(cheap, prices[i]); L9} L10var prices = [4.5, 12, 7.25, 30, 9]; L11Order: L11, L1, L5, L8, L7, L9, L6, L10, L4, L3. Extra: L2
var prices = [4.5, 12, 7.25, 30, 9];
onEvent("cheapButton", "click", function() {
var cheap = [];
for (var i = 0; i < prices.length; i++) {
if (prices[i] < 10) {
appendItem(cheap, prices[i]);
}
}
setText("cheapLabel", cheap);
}); Extra strip: appendItem(cheap, i);. i is the index, not the price. The label shows 0,2,4.