Click here to Skip to main content
15,920,005 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
JavaScript
const items = [
    { name: 'Bike', price: 100 },
    { name: 'TV', price: 200 },
    { name: 'Album', price: 10 },
    { name: 'Book', price: 5 },
    { name: 'Phone', price: 2000 },
    { name: 'Keyboard', price: 50 },
    { name: 'Mouse', price: 500 },
    { name: 'Computer', price: 30 },
]

const foundItem = Boolean(items.length) && items.filter(item => item.price === 10)

console.log(foundItem)



what is happening in the above code?

What I have tried:

I have tried to understand but failed to understand
Posted
Updated 4-Jan-21 19:38pm

1 solution

Try learning JavaScript[^].

Your code has Booleans[^] & filter[^] with Operators[^] .

console.log()[^] gives writes the output.

Do practice & play with multiple version code to master. Current code will print one item name(? - You find it).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900