I have a function that builds an array with push.
function one(resultsArray) {
activity_basic_weight = 9;
for (i in resultsArray) {
score = 0;
score = resultsArray[i].var_a * activity_basic_weight;
score = Math.round(score * 100) / 100;
if (score >= 80)
{
verygoodCategories1.push({
score: score,
name: i,
url: resultsArray[i].url
});
}
else if (score <= 79)
{
...
}
}
two(verygoodCategories1, ...);
}
function two(verygoodCategories1, ...) {
alert(verygoodCategories1.length); // = 7, correct;
// here comes the problem:
for (var i = 0; i < verygoodCategories1.length; i++) {
//this throws "Error: TypeError: verygoodCategories1 is undefined"
}
}
I am new at Javascript. Am I doing something fundamentally wrong?
This is pseudocode, but I made sure that at least the variable names are correct etc.
Any ideas?
Thanks
J