const birthdate3 = {
day: 26,
month: 1,
year: 2025
}
function daysUntilBirthday(birthdate) {
const now = new Date()
const birth = new Date(birthdate.year, birthdate.month - 1, birthdate.day);
const sumday = now.getDate()-birth.getDate()
const summonth = now.getMonth() - birth.getMonth()
const sumears = (now.getFullYear()-birth.getFullYear())*365
if(now.getFullYear()===birth.getFullYear() && now.getMonth()===birth.getMonth()){
return sumday;
}if (now.getFullYear() === birth.getFullYear() && now.getMonth() > birth.getMonth()){
return sumday +(30 * summonth)
}if(now.getFullYear()===birth.getFullYear() && now.getMonth()< birth.getMonth()){
return sumday + (-30 * summonth)
}if(now.getFullYear()> birth.getFullYear()&& now.getMonth()===birth.getMonth()&& now.getDate()=== birth.getDate()){
return sumears
}if (now.getFullYear()> birth.getFullYear()&& now.getMonth()>birth.getMonth()&& now.getDate()=== birth.getDate()){
return sumears + (12 * 30)
}
return birth
console.log(sumday + (30 * summonth));
}
console.log(daysUntilBirthday(birthdate3));
Code will run automatically after changes.
Code runs in an isolated environment.
Code runs in an isolated environment.