JSFiddle - React, Tailwind, and code Playground
by fresheyeball
JavaScript
function calculator(add, subtract) {
var topNum = 2;//document.getElementById("top").value;
var btmNum = 2; //document.getElementById("btm").value;
this.add = add;
this.subtract = subtract;
this.answer = ans;
var that = this;
this.getAnswer = function() {
return that.answer;
}
this.setAdd = function(topNum,btmNum){
that.answer = Math.abs(topNum + btmNum);
}
/* this.setSubtract = function(topNum - btmNum) {
answer = Math.abs(topNum - btmNum);
}); */
alert(this.answer);
}
window.onload = calculator;