Line 3: The function uses a case / switch methodology. Often rather than having a series of if / else statements we can use a case switch method with the same result with much less code and consequently more efficient processing of the script. A basic format for case switching is as follows.
switch (expression) {
case label1:
// Code to be executed
break;
case label2:
// Code to be executed
break;
}
In our code the expression is signified by an argument so that later we can use the labels of each case and call them from an event handler. By way of example,