My JavaScript array looks like this.
[
{id:1, msg:"Your Acct 123XXXX456 Has Been Debited with USD2,100.00 On 05-
MAY- 2019 07:26:58 By AB: 123456**7899/USER NAME/0505201. Bal:
USD973.28CR"}, <br/>
{id:1, msg: "Your Acct 123XXXX456 Has Been Debited with USD1,100.00 On
05-MAY-2019 07:26:58 By AB: 123456**7899/USER NAME/0505201. Bal:
USD673.28CR"},<br/>
{id:2, msg: "Your Acct 345XXXX678 Has Been Debited with USD4,100.00 On
05-MAY-2019 07:26:58 By AB: 11111**22222/USER NAME/0505201. Bal:
USD373.28CR"}
]
I need to pick the following details:
(1) Highest Debit amount (for particular user)
(2) Lowest Debit amount (for particular user)
(3) Sum all the debit amount for particular user.
I tried the following approach to get the non-digits from string.
let result = myArr[0].replace(/\D+/g, ' ').trim().split(' ').map(e =>
parseInt(e));
But output was like this.
[123,456,2,1,00,5]
This approach is putting comma in front of each digit, removing decimal point with preceding 00. I don't have any idea how to pick only debit amount. I am expecting output like this:
User Highest Debit Lowest Debit Total Debit
1 2,100.00 1,100.00 3,200.00
2 4,100.00 4,100.00 4,100.00
myArr = [{
"id": 1,
"msg": "Your Acct 123XXXX456 Has Been Debited with USD2,100.00 On 05- MAY - 2019 07: 26: 58 By AB: 123456 ** 7899 / USER NAME / 0505201. Bal: USD973 .28 CR "
},
{
"id": 1,
"msg": "Your Acct 123XXXX456 Has Been Debited with USD1,100.00 On 05 - MAY - 2019 07: 26: 58 By AB: 123456 ** 7899 / USER NAME / 0505201. Bal: USD673 .28 CR "
},
{
"id": 2,
"msg": "Your Acct 345XXXX678 Has Been Debited with USD4,100.00 On 05 - MAY - 2019 07: 26: 58 By AB: 11111 ** 22222 / USER NAME / 0505201. Bal: USD373 .28 CR "
}
]
let result = myArr[0].replace(/\D+/g, ' ').trim().split(' ').map(e =>
parseInt(e));
console.log(result)
myArr[0]is an object. You need to usemyArr[0].msg.replace