Ho sempre creduto che usare l'undefined nelle condizioni non sia una buona pratica...

Puoi usare piuttosto:

if(primoDay||primoDay==0)