I have written the following code in JavaScript:
var num=1;
var a=0;
while(a==0){
num +=1;
//some logic
//some logic
validate();
alert(num);
}
function validate(){
//some logic
//some logic
if(num==2){
a=1;
}
//some logic
//some logic
}
Here I am getting alert of 1, 2, 3.. but a is not becoming 1. I have observed that validate(); function is not completed, but the execution is moved to next iteration. Could anyone help me figure this out?