rodchar said:
ph_area_1_appraiser_score
ph_area_2_appraiser_score
ph_area_3_appraiser_score
ph_area_4_appraiser_score
ph_area_5_appraiser_score
what do you suggest?
At least an array of scores. However the fact that the variable has a clear
indexer in the middle variable name implies that there may be other
variables such as:-
ph_area_2_some_other_property
Which would might describe some other property of a 'ph_area object'.
So perhaps an array objects is actually called for e.g.:-
function PhArea() {}
PhArea.prototype.putAppraiserScore = function(value)
{
this.appraiserScore = parseInt(value).valueOrZero();
}
var aPhArea = new Array(5);
aPhArea.push(new PhArea())
aPhArea.push(new PhArea())
aPhArea.push(new PhArea())
aPhArea.push(new PhArea())
aPhArea.push(new PhArea())
aPhArea(0).putAppraiserScore('5')
aPhArea(1).putAppraiserScore('0')
aPhArea(2).putAppraiserScore('rubbish')
aPhArea(3).putAppraiserScore('10 green bottles') //what should happen here?
aPhArea(4).putAppraiserScore('5,000,000') // and here?
for (var i = 0; i < aPhArea.length; i++)
{
var phArea = aPhArea(i);
// code that does stuff with each phArea object.
}
When you find yourself creating many variables you should ask yourself, Is
there actually a collection of some form here? and, Do a set of variables
actually describe an object?