Shipping costs $4 for up to 5 pounds, plus $2 for every pound over 5. When someone clicks the costButton button, save the cost in the cost variable, then show the weight and the cost in the costLabel label.
If someone types 8 into the weightInput text box, the label shows 8 pounds costs $10.
11 strips: G1 to G11
cost = 4; G1}); G2setText("costLabel", weight + " pounds costs $" + cost); G3} G4cost = 4 + weight - 5 * 2; G5var cost = 0; G6} else { G7var weight = getNumber("weightInput"); G8onEvent("costButton", "click", function() { G9if (weight <= 5) { G10cost = 4 + (weight - 5) * 2; G11Order: G9, G8, G6, G10, G1, G7, G11, G4, G3, G2. Extra: G5
Lines with the same mark can go in either order.
onEvent("costButton", "click", function() {
var weight = getNumber("weightInput");
var cost = 0;
if (weight <= 5) {
cost = 4;
} else {
cost = 4 + (weight - 5) * 2;
}
setText("costLabel", weight + " pounds costs $" + cost);
}); Extra strip: cost = 4 + weight - 5 * 2;. * goes before + and -, so for 8 pounds this is 4 + 8 - 10, which is 2.