I wanted to list all users who are having birthday in current month in an ascending order.
const user = [
{
name: 'xxx',
dob: '21-09-1988'
},
{
name: 'yyy',
dob: '30-09-2000'
},
{
name: 'zzz',
dob: '01-10-1988'
},
]
Below is my code
const today = new Date();
this.members.forEach((member) => {
let birthdate = member.dob.split('-')[0];
let birthmonth = member.dob.split('-')[1];
console.log(birthmonth);
if (birthmonth === today.getMonth()+1) {
this.birthdayMembers.push(member);
}
});
Please help to resolve this.