Answer to Question #332147 in HTML/JavaScript Web Application for sandhya

Question #332147

bunty birthday:

hey!!its bunty bithday

bunty was born on 13 June 2000 he is curious to know ow many people in is locality have their birthdays on the same day,month,year

given buntyBirthday in the prefilled code and a birthdayList as an input, write js program to find the number of people having their birthdays

on the same day

in the same month

in the same year

input:['2000-05-13' , 'June 7 2021' ,'03/24/2000']

output:


1

2

["2011-12-31","2011-02-14",'June 17 1998','12/02/1990','1995-10-23']

o/p:


1



1
Expert's answer
2022-04-22T13:30:44-0400
let  birthDay = new Date('June 13 2000');
let dates = ['2000-05-13' , 'June 7 2021' ,'03/24/2000'].map(x => new Date(x));


let result = {
    days: 0,
    months:0,
    years:0
};


dates.forEach(x => {
    if(x.getDate() === birthDay.getDate())
        result.days++;


    if(x.getMonth() === birthDay.getMonth())
        result.months++;
    
    if(x.getFullYear() === birthDay.getFullYear())
        result.years++;
});


console.log(result.days);
console.log(result.months);
console.log(result.years);

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS