I have an array of object,I need to get those objects only whose property “name” having similar value.I have provided the expected output also.Here is the code below.
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript</h2>
<script>
const value =
[
{
"id": 2,
"name": "Pumpkin"
},
{
"id": 1,
"name": "Ladies Finger"
},
{
"id": 4,
"name": "Spinach"
},
{
"id": 5,
"name": "Spinach"
}
]
console.log("get same value property")
/*Expected output
[
{
"id": 4,
"name": "Spinach"
},
{
"id": 5,
"name": "Spinach"
}
]
*/
</script>
</body>
</html>