Working on a TV timetable thing... I have an array of objects with dates as properties, like this:
let episodes = [
{"episodeName":"Welcome to the Hellmouth","episodeDate": new Date(1997, 2, 10)},
{"episodeName":"The Harvest","episodeDate": new Date(1997, 2, 10)},
{"episodeName":"Witch","episodeDate": new Date(1997, 2, 17)}]
For some reason, if I try to use a function, it doesn't seem to register any episodeDate as the same as another Date -- it basically just functions as a string.
var testDate = new Date(1997, 2, 10);
let test = episodes.find(test => test.episodeDate === testDate);
console.log(test);
This returns undefined. But if I search using episodeName, for example, in the same function, it works.
My desire is for user input to enter a date and I show what episode aired nearest that date. I've looked at tutorials and understand how to calculate nearest date from an array, but I don't understand how to do that while the date is in an object in an array-- should I convert it? Should I make it into a string?
I'm pretty new to JS.