Trying to make array with certain length

I’m trying to create an array from two other arrays using a loop, where in both arrays I compare two strings and when I find two strings that are the same I push the value to the array from second compared array, and if I don’t find it I push 0. The problem is that the array has to be exactly the length of the first array.
const array1 = ['21', '22', '23', '24', '25', '26', '27'] const array2 = [{score: 1, date: '21'}, {score: 3, date: '23'} ]
output should look like this: const array 3 = [1, 0, 3, 0, 0, 0, 0] <=== this array must have length of array1, and i have problem to create proper loop, or maybe this is shouldnt be loop? Please help.