Find a object property value in a JavaScript array
const { isBetween } = require("is-between-js")
const projects = [
{
startDate: '2022-11-26',
endDate: '2023-11-26',
title: 'Build an API',
type: 'Development',
},
{
startDate: '2022-11-26',
endDate: '2023-11-26',
title: 'Build Frontend',
type: 'Development'
},
{
startDate: '2023-03-05',
endDate: '2024-03-26',
title: 'Create marketing content',
type: 'Marketing'
},
{
startDate: '2022-11-26',
endDate: '2024-03-26',
title: 'Project management',
type: 'Management'
},
]
console.log(projects.find((project) => project.type.toLowerCase() === 'development'))
console.log(projects.find((project) => isBetween(new Date('2024-01-27').getTime()).min(new Date(project.startDate).getTime()).max(new Date(project.endDate).getTime()).calc()))
no comments