The program I am trying to write is a little more complicated but here is a simple addition and subtraction evaluation code to help understand what I am trying to do.
let x0 = document.getElementsByClassName('x0').value;
let y0 = document.getElementsByClassName('y0').value;
function addTion(num1, num2) {
return (num1 + num2);
}
function subTion(num1, num2) {
return (num1 - num2);
}
function Evaluate() {
if (x0 > y0) {
console.log(addTion(x0, y0));
console.log(x0);
} else if (x0 < y0) {
console.log(subTion(x0, y0));
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name='viewpoint' content="width=device-width,
initial-scale=1.0">
<title> Interp-Xtrap</title>
</head>
<body>
<div>
<form name="getData">
<label for="x0">X0:</label>
<input type="text" id="point" name="x0" size="10px">
<label for="y0">Y0:</label>
<input type="text" id="point" name="y0" size="10px">
<button type="button" id="button" onclick=Evaluate()>Evaluate</button>
</form>
</div>
</body>
When I input 1 and 2 for X0 and Y0 respectively, I expect to see -1 as result. #What is the problem with my code?