Here’s my code
var isNew = true
function limb(a,b)
{
if (isNew=true)
{
post(a,b);
isNew = false;
post ("first");
}
else
{
post(a,b);
post ("not first");
}
}
The problem I’m having is that else condition is never triggered. I’m assuming value of isNew is never updated, but I have no idea why.
In some languages
=is used both to assign values and to compare them. JavaScript uses different operators for each of these.x = 10always means “setxto10, and give me the value ofx“.x == 10always means “tell me ifxis equal to10“.So your condition could have been
if(isNew == true)and it would have worked. You can also just putif(isNew).