As a newcomer to the world of coding, I recently embarked on learning JavaScript. However, I have encountered an issue with a particular piece of code causing an infinite loop that has left me perplexed. Despite having a birthday(myAge)
function within the loop that should increment my age and make the condition (myAge < 23)
false, it seems to be failing in its functionality. Can someone shed some light on why this is happening?
var myAge = 22
var birthday = function(myAge){
return(myAge + 1);
}
while (myAge < 23){
console.log("You're only 22");
birthday(myAge)
}