DEV Community


Discussion on: Write better code and be a better programmer by NEVER USING ELSE statements

ani03sha profile image
Anirudh Sharma

@dglsparsons , excellent points. However, the code examples are a little difficult to read as all of the code is in the same line. Better readability can be achieved if it is something like below.

function doSomething() { 
    if (!something.OK()) { 
        // return or throw error 
   return something.Do()
Enter fullscreen mode Exit fullscreen mode
graystrider profile image

New line before return please :3

dglsparsons profile image
Douglas Parsons Author

Hey - thanks for pointing this out. I'm not sure what's happened there.

I've fixed it now, so hopefully its much easier to read!