I want that when I press the submit button it adds a value to the array but instead it keeps returning the same value.
$(document).ready(function(){
    if(typeof arr == "undefined"){
        var arr = new Array();
    }
    arr.push(2);
    $("#submit").click(function(){
       console.log(arr);
    });
});
I want it to add a 2 each time I press submit like this: First press
[2]
Second press
[2, 2]
But now the array just stays 2 as if it just refreshes.
 
     
     
    