Hi I tried to do some calculations as following.
The weight value should subtract its value from score. But when I was doing this I got "undefined" as the score variable output. What is the reason? Did I handle the variable declarations correctly?
var score = 10;
var scoresFunc = function (weight) {
console.log(score);
var finalScore = score - weight;
score = score - finalScore;
var scoreForStartingDate = $('#scoreForStartingDate').val();
var scoreForDuration = $('#scoreForDuration').val();
var scoreForProjects = $('#scoreForProjects').val();
var score = score - parseInt(weight);
var a = '';
for (i = 1; scores >= i; i++) {
a += "<option value='" + i + "'>" + i + "</option>";
}
return a;
};
undefinedfor( i = 1; scores >= i... scores is not defined at this point, which is different than undefined, and causes a Reference Error. Define scores. Perhaps you meant var scores = score - parseInt(weight);. In which case you will still get weight * -1 because at that point score is always 0. It is unclear what exactly you are getting at with this question, or what the purpose of this code was.