Javascript - Function Declarations (DRY principle)
Code Life
By Pierre Marsaa
Don't Repeat Yourself
Before each battle, your team does the same three-line warm-up. Three battles, three copies of the same code:
↗️
Loading editor...
↶
↷
If you want to change one word, you have to change it everywhere. A function lets you write the block once, give it a name, and reuse it:
↗️
Loading editor...
↶
↷
Same output, but the code exists in one place only. Programmers call this the DRY principle: Don't Repeat Yourself.
Verify