Row setting value

trying to create journal entry with 2 rows in accounts table ,how to set value by index?

function create_Return(frm){
          frappe.model.with_doctype('Journal Entry', function() {
        
    	       var journalEntry = frappe.model.get_new_doc('Journal Entry');
    	       	var childTable = frappe.model.add_child(journalEntry, 'accounts');
    	       	childTable[0].account=frm.doc.paid_to,
    	       	childTable[0].debit=frm.doc.paid_amount
                 childTable[1].account=frm.doc.paid_from
    	       	childTable[1].credit=frm.doc.paid_amount
}

childTable[0].account

returns error on console 'TypeError: Cannot set property ‘account’ of undefined
how to set the 2 rows values?

Hi, please try

function create_Return(frm){
frappe.model.with_doctype(‘Journal Entry’, function() {

	       var journalEntry = frappe.model.get_new_doc('Journal Entry');
	       	var childTable = frappe.model.add_child(journalEntry, 'accounts');
	       	childTable.account=frm.doc.paid_to,
	       	childTable.debit=frm.doc.paid_amount
             var childTable2 = frappe.model.add_child(journalEntry, 'accounts');
             childTable2.account=frm.doc.paid_from
	       	childTable2.credit=frm.doc.paid_amount

}

@NMyshuk It Works Thanks