I want to check if a skill is in a repeating section if it is I want to increase a value if not I want to add the skill. Problem is it is doing both it find a skill and increases but also add it. I have almost positive this is because getAttrs is asynchronous. Is there any hop if doing this? function incSkill(section,skill,value,stat){
getSectionIDs(section, function(idArray) {
var found = false;
if (idArray.length > 0) {
_.each(idArray, function(currentID, i) {
getAttrs([section+"_" + currentID + "_skill_name",section+"_" + currentID + "_skill_score"], function(values) {
var curSkill = values[section+"_" + idArray[i] + "_skill_name"];
var curScore = parseInt(values[section+"_" + idArray[i] + "_skill_score"]);
if (curSkill === skill){
setAttrs({[section+"_"+idArray[i]+"_skill_score"]:curScore+parseInt(value)});
found = true;
}
})(found);
});
}
if (found === false){
addSkill(section,skill,value,stat);
}
});
}