I am kinda new to javascript and struggling a bit to do this. I have a list of Objects like this on client side (javascript)
[{id:1,amount_spent:15,date:06/16/2017},
{id:1,amount_spent:10,date:06/15/2017},
{id:1,amount_spent:10,date:06/01/2017},
{id:1,amount_spent:15,date:05/22/2017},
{id:1,amount_spent:10,date:05/24/2017},
{id:1,amount_spent:15,date:04/18/2017},
{id:1,amount_spent:10,date:04/19/2017},
{id:1,amount_spent:15,date:04/19/2016}]
now, I want to group them on weekly basis some how and display it in html as
note: Week start day is always Sunday and Week End day is always Saturday
week start: 06/11/2017 || week end: 06/17/2017
total amount spent = 25
week start: 05/28/2017 || week end: 05/03/2017
total amount spent = 10
week start: 05/21/2017 || week end: 05/27/2017
total amount spent = 25
week start: 04/16/2017 || week end: 04/22/2017
total amount spent = 25
week start: 04/17/2016 || week end: 04/23/2016
total amount spent = 15
and also I want to display it for monthly basis and yearly basis
example for yearly basis grouping on the sample json data:
year 2017
total amount spent = 85
year 2016
total amount spent = 15
Thanks in advance