Write the tip() function first. Two parameters are passed in: total and percent. It returns the tip, rounded to a whole number. Then, when someone clicks the tipButton button, find a 20 percent tip on the bill in the billInput text box. Show the tip in the tipLabel label.
If someone types 45 into the billInput text box, the label shows Tip: $9.
10 strips: N1 to N10
}); N1function tip(total, percent) { N2onEvent("tipButton", "click", function() { N3var answer = tip(bill, 20); N4return Math.round(amount); N5setText("tipLabel", "Tip: $" + tip); N6var bill = getNumber("billInput"); N7var amount = total * percent / 100; N8} N9setText("tipLabel", "Tip: $" + answer); N10Order: N2, N8, N5, N9, N3, N7, N4, N10, N1. Extra: N6
function tip(total, percent) {
var amount = total * percent / 100;
return Math.round(amount);
}
onEvent("tipButton", "click", function() {
var bill = getNumber("billInput");
var answer = tip(bill, 20);
setText("tipLabel", "Tip: $" + answer);
}); Extra strip: setText("tipLabel", "Tip: $" + tip);. tip is the function itself, not what it returns. The tip it returned is in the answer variable.