This particular script is designed to scan through a sheet for currency values and create key/value pairs for a JSON based on the column and row headers. It basically detects a currency value, then traces back row and column numbers until it reaches a non-currency, non-blank value which is used along with the currency to form pairs. There are three functions involved: one to enable the second by identifying if a value is currency, the second function builds the object, and the third one iterates through the sheets and constructs the object for each sheet that meets specific criteria.
Each sheet is named following a pattern like "name_name_type_location", and the specified criteria is anything with the type "AF".
The problem encountered is when calling tariffObject(sheets[i]) within publishedSheets(), it appears to disrupt the for loop, resulting in only receiving the first sheet object even though there are more than four sheets meeting the criteria. Removing the tariffObject(sheets[i]) call resolves the issue. There seems to be something causing this loop interruption.
How can this be resolved?
function isCurr(x){
var regex = /^[$]\d+(?:\.\d{0,2})$/;
if (regex.test(x)){
return true;
}
else{
return false;
}
}
function tariffObject(sheet){
// Function code...
}
function publishedSheets(){
// Function code...
}