Q:

Using Variables to create function prior to assigning to variable

I am trying to modify the column.filterable.ui in a kendo ui grid.  To do this, I can do the following:
 filterable.ui = function (element) { 
   element.kendoNumericTextBox({ format: 'n2', decimals: 2 }); 
 };

However, I want to be able to change the format based on a variable let's call it x.  With a string, I could just concatenate it, but with a function definition I'm clueless.

A:

var x = true;

filterable.ui = function (element) { 
   var fmt = 'n2';
   if (x === true) {
     fmt = 'y2';
   }
   element.kendoNumericTextBox({ format: fmt, decimals: 2 }); 
};

