I'm trying to automatically create Google docs by looking at my student scores. I have an if statement that checks the score, assigns a value and a function that prints the same. Everything seems to work, except that my if statement always returns the first value. How do I fix this?
Here is my code:
function createPdf() {
const ws = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Summary');
const lastRow = ws.getLastRow();
const score = ws.getRange(lastRow, 3).getValue();
const templateDoc = DriveApp.getFileById('test1');
const newTempFile = templateDoc.makeCopy(tempFolder);
const openDoc = DocumentApp.openById(newTempFile.getId());
const body = openDoc.getBody();
const paragraph = body.getParagraphs();
body.replaceText('{percentage}', percentage);
body.replaceText('{score}', score);
if (50.0 < score < 120.0) {
paragraph[13].appendText('POOR') && paragraph[17].appendText('xyz.');
} else if (score >= 120.0) {
paragraph[13].appendText('GOOD') && paragraph[17].appendText('abc.');
} else {
paragraph[13].appendText('VERY POOR') && paragraph[17].appendText('ouy.');
}
openDoc.saveAndClose();
}