How to avoid code duplication script?

There are two fields: name and date.
When you enter data the font scales with the help of small script plug-in inputfit.

The problem is that for the first field I have a maximum text height of 60px, and 30px for the second. And option this is regulated in the code of the plugin. How to make it I don't know.

At the moment, stupidly copied the code with a different name and used for two fields of two different plugin, but it doesn't work. As it is right to decide?

Example here: https://jsfiddle.net/962p3ffd/1/
June 8th 19 at 17:23
3 answers
June 8th 19 at 17:25
Solution
$('.input-name').inputfit({maxSize: 60});
$('.input-date').inputfit({maxSize: 30});
June 8th 19 at 17:27
Solution
You have to learn code to read:
$('.input-name').inputfit({ maxSize: 60 });
$('.input-date').inputfit({ maxSize: 30 });


Climb to the implementation of vendor libraries is a very bad practice. It is not necessary to do so. Usually, as in this case, the authors of the libraries provide an interface for its configuration.
June 8th 19 at 17:29
Solution
Remove the maxSize value in the data parameter input and take it into your function

Find more questions by tags JavaScriptjQuery