This is a sample showing how a function can be used to reuse a piece of code.
NOTE: It's just for educational purpose, not a real world application and it doesn't necessary follow all the best development praticies.
It's the result of an article explaing programming logic, in portuguese - O que é lógica de programação afinal?
- Clone this repository
git clone git@github.com:programadorsemfronteira/functions_use_sample.git; - Run
npm installinstalling dependencies; - Run
npm run testverifying the current implementation is working.
The current implementation uses a function called hasAccess shared between modules.
An implementation without using this function is available as well on a previous commit.
- Verify the different commit running
git checkout b24115b66f291250dc13b1ebdf0a89f131902f1b - Run
npm run testverifying the implementation is still working.
NOTE: Once you have done, run git switch - switching back to the main implementation.