The collectTypes() method from the Magento_BraintreeTwo's validator.js can be simplified from 8 lines to 1

The method produces array intersection by keys, the same as array_intersect_key PHP function.
It can be simplified to the single line:

return _.pick(availableTypes, _.intersection(_.keys(availableTypes), _.keys(countrySpecificCardTypes)));

See also: