var Obj = {
StateValues: ['AL','AK','AL','AK','AZ','AR','CA','CO','CT','DE','FL','GA','HI','ID','IL','IN','IA',
'KS','KY','LA','ME','MD','MA','MI','MN','MS','MO','MT','NE','NV','NH','NJ','NM','NY','NC','ND',
'OH','OK','OR','PA','RI','SC','SD','TN','TX','UT','VT','VA','WA','WV','WI','WY'],
getItemRow: function(itemValue) {
var myPosition=-1
for (i=0;i<this.StateValues.length;i++) {
if(this.StateValues[i]==itemValue) {
myPosition = i;
break;
}
}
return myPosition;
}
}
What’s wrong with this piece of code. Am i declaring the correct way. The issue started after adding the array in my Object.
You’re using
thiswrongly. It is referring towindow(the global object).Try this instead: