Try this:
function myfunk1() {
const ss = SpreadsheetApp.getActive();
const sh = ss.getSheetByName('Your sheet name');
const sum = sh.getRange(2,2,sh.getLastRow() -2,1).getDisplayValues().reduce((a,c)=>{ a+=parseFloat(c);return a;},0);
sh.getRange(2,1,sh.getLastRow() - 1).getValues().forEach((r,i) => {if(r[0]=='sum')sh.getRange(i + 2,2).setValue(Number(sum).toFixed(2))});
}
Ouput:
| Item | Cost |
|---|---|
| 1 | 57.9 |
| 2 | 111.9 |
| 3 | 39.9 |
| sum | 209.7 |