This is my HTML for the moment
<input type="text" id="input"><br>
<input type="text" id="Result"><br>
<button id="input-button" onclick="inputNumero()">Add it in</button>
<button id="calculate" onclick="calculator()">Calculate</button>
and the javascript to go along with it is
var input = document.getElementById("input");
var output = document.getElementById("Result");
var counter = 0;
var Numero = [];
function calculator() {
var result = 0;
if (counter < 4) {
return alert("Missing A few numbers");
}
for (var i=0;i<4;i++) {
result += parseFloat(Numero[i]);
}
output.value = parseFloat(result);
counter = 0;
Numero = [];
}
function inputNumero() {
if (counter === 4) {
return alert("You are putting too many numbers");
}
Numero.push(parseFloat(input.value));
counter++;
output.value = Numero.toString();
}
for some reason when it is inputted into codepen it will fully run and work perfectly however when put into Google Chrome it is implying that there is an error in the javascript.
EDIT: The error that Chrome and other browsers output is : Uncaught TypeError: Cannot read property 'value' of null