Can anyone explain why this is not working:
var todayDate = new Date();
var todayYear = todayDate.getFullYear();
var User = {
firstName: "John",
lastName: "Doe",
email: "email@email.com",
dob: new Date(85, 1, 1),
userBirthYear: dob.getFullYear(),
age: todayYear - userBirthYear,
url: "http://www.google.com",
bio: "I love pizza",
interests: ["food", "NBA", "movies"]
}
The userBirthYear
doesn't seem to be initializing. If I move the userBirthYear
outside the object as a separate variable, it works fine.