Modo entrevista. Cronômetro de 4 min, sem dicas e sem autocompletar
Required fields
FácilJSON and data4 min
An API returned an ad item, and the array required lists the fields it must have. Write a function missingFields(item, required) that returns an array of the fields from required that item does not have, in the order of required.
Exemplos
missingFields({ id: 1, price: 500 }, ['id', 'title', 'price'])Retorna [ 'title' ]
missingFields({ id: 0, title: '' }, ['id', 'title'])Retorna []
Cobrada em Avito · Fonte
Carregando o editor...
- Entrada
missingFields({ id: 1, price: 500 }, [ 'id', 'title', 'price' ])Esperado[ 'title' ] - Entrada
missingFields({ id: 0, title: '' }, [ 'id', 'title' ])Esperado[] - Entrada
missingFields({}, [ 'id', 'title' ])Esperado[ 'id', 'title' ]
Os testes ocultos rodam no envio