I have a problem with a function that returns a specific prize. The prize is bound to SEO score of a webpage. Every webpage has a specific conditions that must be achieved in order for us to get the prize for pushing the word in top 10 on google. The prize that is defined here is a one time deal, thats why it has to be executed only once and then never again after the goals are completed
If the goal for the prize is true then the prize is 3000. The problem is that this prize is a one time deal. So when this goal is completed and the user gets the 3000 prize thats it. If next time the goal is again reached the prize 3000 is not calculcated to the prize. For the goal to be true the variable "st"(the number of words that reached the first page in google) must be 15 or equal and lower than 20. The second prize is given if "st" is bigger or equal then 20. Both can happen only once, or both at the same time. Lets say that the first goal ( qual or bigger than 15, but lower than 20) is not reached, and if "st" is 21 both prizes are calculated (so 6000) once and then never again. For now I have two gloabal variabels that have a false value, and then the if else sentences to return the prize.
var prize1= false;
var prize2= false;
if (st >= 15 && st < 20) {
prize1= true;
if (prize1) {
return 3000;
}
}
else if (st <= 20 && prize1) {
prize2= true;
if (prize2) {
return 3000;
}
}
else if (st <= 20 && !prize1) {
prize2= true;
if (prize2) {
return 6000;
}
}
The problem is that this happens everytime when the goal is completed and not just only once.