Search This Blog

Friday, February 4, 2022

Higher order functions

 Iterating the array of objects and changing the value of object


const products = [ { name: 'Laptop', price: 32000, brand: 'Lenovo', color: 'Silver' },
    { name: 'Phone', price: 700, brand: 'Iphone', color: 'Golden' },
    { name: 'Watch', price: 3000, brand: 'Casio', color: 'Yellow' },
    { name: 'Aunglass', price: 300, brand: 'Ribon', color: 'Blue' },
    { name: 'Camera', price: 9000, brand: 'Lenovo', color: 'Gray' },
];

var results = [];
for(let i = 0; i < products.length; i++)
{
    //console.log(products[i]);

    products[i].name = products[i].name.toUpperCase();

    results.push(products[i]);
   
}

No comments:

Post a Comment

Validating to select in sequencial order using angular

    < input type = "checkbox" (change) = "handleSelectTaskItem($event, taskItem)" [checked] = " taskItem . i...