If we consider a variable called data, can we extract specific items from an array based on the totalaccount value? For instance, before the first occurrence of totalaccount, there are three accounts that I want to retrieve.
Similarly, before the final totalaccount excluding the initial one, there are two accounts for which I need information extraction. How can we transform the array into the desired format below?
let firstOne = {loanname: "Mr X", acnumber: "020000000000001", outstanding: "54000"},
{loanname: "Mrs Y", acnumber: "020000000000087", outstanding: "87000"},
{loanname: "Mr Z", acnumber: "020000000000103", outstanding: "15000"},
let secondOne ={loanname: "David", acnumber: "020000000000091", outstanding: "11000"},
{loanname: "James", acnumber: "020000000001291", outstanding: "4000"},