// Lesson 2: read values, loop, decide, write results.
function main(workbook: ExcelScript.Workbook) {
  const sheet = workbook.getActiveWorksheet();
  const data = sheet.getRange("A2:B6").getValues();   // [[name, marks], ...]
  let passed = 0;
  const results: string[][] = [];
  for (const row of data) {
    const marks = row[1] as number;
    const result = marks >= 40 ? "Pass" : "Fail";
    if (result === "Pass") passed++;
    results.push([result]);
  }
  sheet.getRange("C2:C6").setValues(results);
  console.log(`Passed: ${passed} of ${data.length}`);
}
