Modo entrevista. Cronômetro de 5 min, sem dicas e sem autocompletar
All even
FácilFunctions5 min
Write two functions for an array of integers. The numbers can be negative.
isEachEven(numbers) returns true if every number is even and false if not.
firstOdd(numbers) returns the first odd number, or undefined if there are no odd numbers.
Exemplos
isEachEven([2, 4, 6])Retorna true
isEachEven([2, 3, 4])Retorna false
isEachEven([])Retorna true
firstOdd([2, -3, 5])Retorna -3
firstOdd([2, 4])Retorna undefined
Carregando o editor...
- Entrada
isEachEven([ 2, 4, 6 ])Esperadotrue - Entrada
isEachEven([ 2, 3, 4 ])Esperadofalse - Entrada
isEachEven([])Esperadotrue - firstOdd finds the first odd number
- firstOdd with no odd numbers returns undefined
Os testes ocultos rodam no envio