Code Lab

0, 0, 7 in order

EasyArrays7 min

Write a function has007(numbers) that returns true if the array has 0, 0 and 7 in this order, and false if not. Other numbers may stand between them.

Examples

has007([1, 0, 2, 4, 0, 5, 7])

Returns true

has007([1, 7, 0, 0])

Returns false

The seven comes before the zeros.
has007([0, 1, 7, 0])

Returns false

Only one zero comes before the seven.

Asked at Druva · Source

Loading the editor...
  1. Inputhas007([ 1, 0, 2, 4, 0, 5, 7 ])
    Expectedtrue
  2. Inputhas007([ 1, 7, 0, 0 ])
    Expectedfalse
  3. Inputhas007([ 0, 1, 7, 0 ])
    Expectedfalse

Hidden tests run on Submit.