param formats param preferredFormats returns export function getPreferredFormat ( formats , preferredFormats ) { for ( let i = 0 ; i < preferredFormats . length ; i ++ ) { if ( formats . indexOf ( preferredFormats [ i ] ) > - 1 ) { return preferredFormats [ i ] ; } } return formats [ 0 ] ; }