There is a task to obtain data about a person and calculate days to others with the help of classes and constructors using a het, a set.
class Persona { constructor(first, last, day, month, year) { this.name = { first, last }; this.Birthday = { day, month, year }; } get fullName() { return `${this.name.first} ${this.name.last}`; } } var person1 = new Persona('Name', 'Surname', 11, 11, 1111); console.log(person1.fullName); I didn’t finish the code, because I don’t understand how to calculate correctly, I found a function that, in theory, it does.
function daysLeft() { var year = parseInt(prompt('enter year (format: YYYY)')); var month = parseInt(prompt('enter month (format: M)')); var day = parseInt(prompt('enter day')); var today = new Date(); today.setHours(0,0,0,0); var nextDate = new Date([today.getFullYear(),month,day].join(',')); if (nextDate < today) nextDate.setFullYear(today.getFullYear()+1); msPerDay = 24*60*60*1000; daysLeft = Math.round((nextDate.getTime() - today.getTime())/msPerDay); dayname = ""; ds = ""+daysLeft; dd=parseInt(ds.substr(ds.length-1)); } } help pliz correctly write everything down