Need help combining two arrays:
var scores = [
{ user: "Alice", score: 22 },
{ user: "Sam", score: 30 },
{ user: "Linda", score: 14 }
]
var ranks = [
{ name: "Alice", rank: 1 },
{ name: "Sam", rank: 2 },
{ name: "Linda", rank: 3 }
]
Is there a way to merge these arrays into a single array like this:
var combined = [
{ name: "Alice", rank: 1, score: 22 },
{ name: "Sam", rank: 2, score: 30 },
{ name: "Linda", rank: 3, score: 14 }
]
Matching the scores with the corresponding names from the first array?