• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

166
Views
Creating new object from data and exclude double values

Could not find a working solution but I am creating a new object from some data inside a loop but the date contains double values so it should prevent this from adding to the new object. The name property should contain unique values only.

public listOfItems: {[key: number]: {name: string; inStock: boolean}} = {};
dataAndStuff.forEach((item, i) => {
    this.listOfItems[i] = {
        name: item.itemName,
        instock: false,
    };
});

// output
[
    {name: 'audi', inStock: true}
    {name: 'bmw', inStock: true}
    {name: 'audi', inStock: true}
    {name: 'kia', inStock: true}
]
about 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error