1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| try {
if (operator == "plus")
cocoon.sendPage("result.html", {result: a + b});
else if (operator == "minus")
cocoon.sendPage("result.html", {result: a - b});
else if (operator == "multiply")
cocoon.sendPage("result.html", {result: a * b});
else if (operator == "divide")
cocoon.sendPage("result.html", {result: a / b});
else
cocoon.sendPage("invalidOperator.html", {operator: operator});
}
catch (e) {
cocoon.sendPage("error.html",
{message: "Operation failed: " + e.toString()});
}
|