i am facing a confused how can i terminate a loop when i get the correct value from iteration. I have pasted a code snippet below. What i am trying to do is that i have one string called skillID, and other array called emplSkillLevel. When skillID does match in the loop, then it returns the string after setting the value in string but at some points loop doesn't break it.
How can i terminate it?
setCellValue: function(skillID,emplSkillLevel){
var cellVal=0;
$.each(emplSkillLevel, function(index1, item1) {
var emplSkillLevelID = emplSkillLevel[index1].split("-");
if(emplSkillLevelID[0] == skillID){
cellVal = emplSkillLevelID[1];
return cellVal;
break;
}
else{
cellVal=0;
return cellVal;
}
});
}