I have this lst, which has the name and total available.
let lst = [
{ name: 'Apple', total: 4 },
{ name: 'Mango', total: 9 },
{ name: 'Orange', total: 6 },
{ name: 'Passion', total: 2 }
]
Now there is a new list json which I receive from an api, that only has names of the items, I changed to an array like this.
let newlst = ["Apple","Orange","Banana","Mango","Apple","Pineapple","Passion"]
So how do I go on about for each item in newlst that is found in lst array then sum their total +1 .... If not then skip.
So expected out is
let lst = [
{ name: 'Apple', total: 6 },
{ name: 'Mango', total: 10 },
{ name: 'Orange', total: 7 },
{ name: 'Passion', total: 3 }
]