Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

Find a object property value in a JavaScript array

node v18.11.0
version: 2.0.0
endpointsharetweet
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()))
Loading…

no comments

    sign in to comment