Develop a component that merges two hardcoded arrays of objects based on a common property and displays the merged array.
HardProblem Statement
Develop a component that merges two hardcoded arrays of objects based on a common property and displays the merged array.
Sample Input
[{ "id": 1, "name": "Alice" }, { "id": 2, "name": "Bob" }]
[{ "id": 1, "age": 25 }, { "id": 2, "age": 30 }]Sample Output
Merged Array: [{ id: 1, name: 'Alice', age: 25 }, { id: 2, name: 'Bob', age: 30 }]Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
import React from "react";
const MergeArrays = () => {
return (
<div>
{/* Display the merged array */}
</div>
);
};
export default MergeArrays;
Input
[{ "id": 1, "name": "Alice" }, { "id": 2, "name": "Bob" }]
[{ "id": 1, "age": 25 }, { "id": 2, "age": 30 }]Expected Output
Merged Array: [{ id: 1, name: 'Alice', age: 25 }, { id: 2, name: 'Bob', age: 30 }]