Why do we declare a var getToDaChoppa?



Code behaves correctly. My question is however, why do we declare the var getToDaChoppa and then enter the do/while loop inside it?

If I remove that variable and function it does not effect the outcome.

var getToDaChoppa = function(){
  do {
      console.log("Do you even lift bro")
  } while(understand);

var understand = false



Declaring it in a function makes the code reusable and easier to call instead of continually writing it every time you want to perform that specific action.


That's one of the aspects of functional programming.