Validar JavaScript de CEP

function isZipCode(str) 
{
  return /^\d{5}(-\d{4})?$/.test(str);
}
Undefined