I have the following code:
alert('Returned value : ' + myid_templates_editor_image_id_generator()); //Generates unique id for every image created function myid_templates_editor_image_id_generator(){ (function($){ var a = 1; while(true){ if($('#myid_templates_editor_image_' + a).length == 0) { alert('Inside value : ' a); return a; } a++; } })(jQuery); }
He warns twice:


Why is the value undefined returned? It should be 1 . Where am I missing?
source share