I am trying to call a new function under existing function. First function works perfectly, but code does not go inside test function. Any idea on this issue?
The error I get on this is : test is not defined
var doIt;
var test;
$(document).ready(function() {
  test(2);
  doIt = function() { //now has global scope.
    test(1);
  };
  test = function(n) {
    alert('test function');
  }
})<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
  <input name="Go" type="button" value="Go" onclick="doIt();" />
</body> 
    