What is the quickest way to compare two arrays and return a third array containing the values from array2 where the associated values from array1 are true?
const array1 = [true, false, false, true];
const array2 = ['a', 'b', 'c', 'd'];
The result should be:
const result = ['a', 'd'];