Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Why not simply do a straight exit-early if+return?

  if(!username || username.trim() = '')
     return { error: "No Username Given.", field: 'name' };

  if(!password || password.trim() = '')
     return { error: "No Password Given.", field: 'password' };
and so on.

Is that not clever enough??? Even a monkey would understand this.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: