Advertisement
ralitsa_d

Untitled

Oct 23rd, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. function getModel() {
  2. let model = {
  3. init: function (num1Sel, num2Sel, resultSel) {
  4. model.num1 = $(num1Sel);
  5. model.num2 = $(num2Sel);
  6. model.result = $(resultSel);
  7. },
  8. add: () => model.action((a,b) => a + b),
  9. subtract: () => model.action((a, b) => a - b),
  10. action: function (operation) {
  11. let val1 = Number(model.num1.val());
  12. let val2 = Number(model.num2.val());
  13. model.result.val(operation(val1, val2))
  14. }
  15. };
  16. return model;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement