I'm running a function that gets the value of a field name and and sets the desired variable to that field name. The problem is that the variable doesn't return any values and I'm not sure why? There must be something I'm doing wrong but it's just not obvious to me.
var latField, longField;
var fieldNames = csvStore.getAttributes(items[0]);
function findSpecificFieldName(originalField, newFieldArray, matchedField){
var matchId;
matchId = arrayUtils.indexOf(newFieldArray,
originalField);
if (matchId !== -1) {
matchedField = originalField;
}
return matchedField;
}
arrayUtils.forEach(fieldNames, function(fieldName) {
findSpecificFieldName(fieldName, latFieldStrings, latField);
findSpecificFieldName(fieldName, longFieldStrings, longField);
});`
I want the latField variable and longField variable to take the property of the matchedField variable within the function but they don't take it's value. When checking to see if the matchedField variable is equal to the originalField variable it returns the right field but it's not passing that information into the lat and long field variables.