Tony Minseok KimFront End Web Development Techdegree Student 11,682 Points
In real life situation, or workplace situation
So Guil just put all the codes into a function, so that it is more readable and easy to use it over and over again, but I was just wondering when it comes to a real life situation, do you guys usually make functions first or just like Guil, make functions after once you find repeating code lines.
Dane ParchmentTreehouse Moderator 9,724 Points
In the "real-world" it's normally a bit of both. In general, you will be using and creating many functions. But there may be some instances where you find a lot of code repeated in multiple places in your codebase. Instead of just leaving them there, in an effort to be DRY (Don't Repeat Yourself), the common code is generally extracted into a new function.