OK Miko, glad to have helped.
For javascript and any of its variants like google app script, you need to be really familiar with arrays and looping mechanisms. (The same holds true for PHP,.) Look up the javascript for loop on google, or ask chatGPT. You should examine looping through objects, through arrays, etc. Also take a look at the forEach method, which is more advanced and requires so-called anonymous functions.
I find that converting google spreadsheet ranges to arrays to be convenient and efficient. In appscript, the getValues method converts the sheet range into a two-dimensional array of row/column data. This array has the number of rows in the range as the number of elements, or array length. Each row element is in turn an array of all the columnar data in that row. Hence, you go through two "dimensions" to get the value in a particular row/column, but you use straight array indexing, starting from 0.
SO ..the for loop I showed you loops through both arrays ... the rows (in this case, only one, and then within each row, it picks the i-th column (column A havin index 0, and so on.) to grab the key and the value for each combination you are looking for.
I do confess that I still didn't have everything totally correct for you .. even if the sheet range has only one row, and getValue returns only one array element, that array element is a list of all the column data, so you need to reference it that way. Here is a good way to do this:
const outArray = ss.getRange(1,1,2,ss.getLastColumn()),getValues();.
for (i = 0; i < outArray.length; i++) {
doc.replaceText('{' + outArray[0][i] + '}', outArray[1][i])
}
Note that I collapsed this to one array with two elements, the first array element (outArray[0] is an array of the header row column data, and the second element (outArray[1]) is an array of the values attached to the header. The bracketed [i] loops through all the columns. There is a double subscripting for the two dimensional array.