How to fetch some key-value pairs of an object from an array of objects in JavaScript?

I have an array of objects as shown below: const list = [ { username: … Read more How to fetch some key-value pairs of an object from an array of objects in JavaScript?

I have an array of objects as shown below:

const list = [
{
    username: "John",
    title: "HTML, CSS and JavaScript",
    datePublished: "20 May 2021"
},
{
    username: "Jack",
    title: "ReactJS",
    datePublished: "30 June 2021"
},
{
    username: "John",
    title: "JSON",
    datePublished: "16 July 2021"
},
{
    username: "John",
    title: "MongoDB",
    datePublished: "29 September 2021"
},
{
    username: "Jack",
    title: "MERN",
    datePublished: "1 October 2021"
}
]

I want to store title and datePublished associated with the username John as a new array of objects using some JavaScript code/function.
How to do this?

Source: JavaSript – Stack Overflow



Leave a Reply

Your email address will not be published. Required fields are marked *