Hi folks… I’m sure this is really easily solved but looking for help. I’m bumbling my way through this project and trying to push entered digits into an array. It works but replaces rather than pushes the numbers entered into my array… i.e if I click 1,2,3… the console logs the array as [1], then [2], then [3]… whereas I want it to update and show [1,2,3]… Can anyone help with what I am doing wrong?
$(":button").click(function() {
//setup the global variables
var operator = “”;
var firstArr = [];
var result = 0;
//need to push digits entered to an array until we detect an = button
if (($(this).val()) != “=”) {
firstArr.push($(this).val());
}
console.log(firstArr);
$("#screen").html(result);
});