Javascript calculator challenge help

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);
});

thanks Randell
link is here:

Im thinking its because my jscript is re-running the code each time a key is pressed rather than catching all inputs up until the = button is pushed.
stuggling to work it out though.

all good Randell… worked it out finally!! i needed to setup document.ready then my variables then my button click event handler.
It was re-running the function because I had the button handler at the top.

thanks so much for your help. This is tough but fun!