Why do we declare a var getToDaChoppa?


#1


https://www.codecademy.com/courses/javascript-beginner-en-ASGIv/2/3?curriculum_id=506324b3a7dffd00020bf661#

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

getToDaChoppa();


#2

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.


#3

That's one of the aspects of functional programming.