I've tried both these:
if foo
  if foo[0] == bar.baz[0]
    input.form-control-success(type="text")
  else
    input.form-control-danger(type="text")
else
  input(type="text")
unless foo === undefined
  if foo[0] == bar.baz[0]
    input.form-control-success(type="text")
  else
    input.form-control-danger(type="text")
else
  input(type="text")
But in both cases I get the error
Cannot read property '0' of undefined
on the line if foo[0] == bar.baz[0].
The situation is that sometimes foo is passed to pug, and sometimes it isn't.
foo is an array when it is passed, and if it is passed I need to do something based on whether it's xth element is the same as another array's xth element.
 
     
    