Please explain why the variable a in the function makeDiv gets undefined?
var a=10000; (function makeDiv(a){ var b=a+1000; var divsize = ((Math.random()*100) + 50).toFixed(); var color = '#'+ Math.round(0xffffff * Math.random()).toString(16); $newdiv = $('<div/>').css({ 'width':'50px', 'height':'50px', 'background-color': color }); var posx = (Math.random() * ($(document).width() - divsize)).toFixed(); var posy = (Math.random() * ($(document).height() - divsize)).toFixed(); $newdiv.css({ 'position':'absolute', 'left':posx+'px', 'top':posy+'px', 'display':'none' }).appendTo( 'body' ).fadeIn(100).delay(1000).fadeOut(200, function(){ $(this).remove(); makeDiv(); }); console.log(a); })(); <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>