I know the issue is with the array , index.Of() is grabbing -1 which means its grabbing nothing... would i need to rebuild my array to get the correct value? testingsom.js
const lo = require('lodash')
const Holiday = require('./Holidays')
let Holidayslist =
[{
Name: 'New Years Day' ,
date: new Date('January 1 2023')
} ,
,{
Name: 'Christmas' ,
date: new Date(' December 25 2023')
}
,{
Name: 'Canada Day' ,
date: new Date('July 1 2023')
}]
currentTime = Date.now()
for(const Holidays_obj of Holidayslist) {
console.log( Holidays_obj.Name + ' is ' + (Holidays_obj.date - currentTime ) / (1000 * 3600 * 24) + ' ' +'Days away ')
}
random_person = lo.sample(Holidayslist)
//console.log(random_person)
//console.log(Holidayslist[1])
indexArray = lo.indexOf(Holidayslist.indexOf('Christmas'))
console.log(indexArray)
Holidays.js
class Holiday {
constructor(date, Name) {
this.name = Name;
this.date = date; }
}
module.exports = Holiday