TYPES = ['base', 'second', 'sour', 'mixer'] $(document).ready(function() { for (ingredient_type of TYPES) { loadSelect(ingredient_type); } $('select').on('change', function () { onSelectChange(); }) }) function loadSelect(ingredient_type) { $.get(`/api/ingredients/${ingredient_type}`, function (data) { $(`select#${ingredient_type}`).append($('