DEV Community

Discussion on: Explain Empty Returns Like I'm Five

Collapse
 
icetruckcol profile image
IceTruckCol

Some functions are designed to return a value while others have a job to do that doesn't require anything to be returned. Return means exit the function either way but, if the design of the function expects a value to be returned, it must follow return like return 23;

When you start coding, you usually put returns at the end of functions after the work has been done. But after a while returns are placed inside ifs and loops and you usually end up coding multiple returns depending on the state of the application.