DEV Community

loading...

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

Collapse
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
Collapse
graystrider profile image
GrayStrider

New line before return please :3

Collapse
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!