Answers for "map && arrow function in javascript"

0

map && arrow function in javascript

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' },
];
//Total products price by using Map
let total = 0;
const getPrice = products.map(product => {
    total = total + product.price;
});
console.log(total)
//Expected outPut: 45000
Posted by: Guest on September-11-2021
3

arrow function map js

const exampleArray = ['aa','bbc','ccdd'];
console.log(exampleArray.map(a => a.length));
//Would print out [2,3,4]
Posted by: Guest on October-28-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language