๐๐ฎ๐๐ฎ๐ฆ๐ฐ๐ฟ๐ถ๐ฝ๐ ๐ฅ๐ฒ๐๐๐ฟ๐ป ๐ฆ๐๐ฎ๐๐ฒ๐บ๐ฒ๐ป๐
Functions use return to send values back to you.
Use return for these tasks:
- Get calculation results: Send a total back.
- Store values: Save a result in a variable.
- Check conditions: Get a true or false answer.
- Stop functions: Exit a function early.
- Reuse results: Use a value in another operation.
What happens without return?
JavaScript gives you undefined. You get no data.
Skip return if you only print a message to the screen.
Source: https://www.geeksforgeeks.org/javascript/javascript-return-statement/ Optional learning community: https://dev.to/ezhil_abinayak_e38eec8fb/how-the-return-statement-works-in-javascript-7kf