Set child table quantity column by coding

How to set the item child table quantity. for example need to set the quantity and rate value based on some calculation. System need to calculate the amount based on quantity and rate.

frm.doc.items[0].quantity=totalBillableqty;
frm.doc.items[0].amount=totalBillableqty * frm.doc.items[0].rate;

The events not working while assigning like this ?
calculate: function (frm, cdt, cdn) {
let row = frappe.get_doc(cdt, cdn);
frappe.model.set_value(cdt, cdn, “amount”, flt(row.quantity) * flt(row.rate));
},

Reference: Calculate (SUM) two fields and display the result on the third field on child table - #2 by NCP