You should be able to do it by storing the pairs in a nested array—the format would be:
var array = [["search1", "change1"], ["search2","change2"],...]
Maybe this works?
//A nested array in this format [["search1", "change1"], ["search2","change2"],...]
var sa = [["indesign", "InDesign"], ["script panel","Script Panel"], ["graphic objects", "artworks"]]
searchBooks()
function searchBooks(){
try {
var b = app.activeBook
}catch(e) {
alert("No Open Books")
return
}
var bp = b.bookContents.everyItem().fullName;
var d;
for (i = 0; i < bp.length; i++) {
d = app.open(bp[i]);
for (var j = 0; j < sa.length; j++){
grepSearch(sa[j][0],sa[j][1])
};
d.close(SaveOptions.YES);
}
}
/**
* Document Grep find and change
* @ param f the find grep string
* @ param c the change grep string
* @ return void
*/
function grepSearch(f,c){
app.findGrepPreferences = app.changeGrepPreferences = app.findChangeGrepOptions = null;
app.findChangeGrepOptions.properties = {includeFootnotes:true, includeHiddenLayers:true, includeMasterPages:true, wholeWord:false}
app.findGrepPreferences.findWhat = f;
app.changeGrepPreferences.changeTo = c;
app.activeDocument.changeGrep( true )
}