Further understanding of JavaScript

When scripts are being executed, there is something called control flow, which is the sequence of which the the computer will read and run code. As an example, let's say there is a conditional sprit which will promptUser() when a certain condition is met or will submitForm() because the first condition was not met.

                  
  if (field == empty) {
  promptUser();
  } else {
  submitForm();
  }
                  
              

It is typical to find conditionals, loops, and functions in programming languages, since they are the building blocks of code. Some scripts will not be executed if an event has not occurred, which is proven by the example above.

What are functions?

Functions are the engine of a car as an example. The car will only drive if there is someone driving it and will only go as fast as the gear the gear stick is in. Meaning, a certain condition has been met for the car to drive above the of 30mph.