I would like to refactor my javascript code with an function.
ingos - is a name of the company and I have 5th of similar code parts.
$('#ingosRegularPrice').removeClass("inactive");
$('#ingosActivePrice').removeClass("inactive");
$('#ingosRegularPrice .btn span').text(ingosPrice);
$('#ingosActivePrice .btn span').text(ingosPrice * params.ingos.programB);
with something like
function setPriceActive(company){
$('#'+ company + 'RegularPrice').removeClass("inactive");
$('#'+ company + 'ActivePrice').removeClass("inactive");
$('#'+ company + 'RegularPrice .btn span').text(companyPrice);
$('#'+ company + 'ActivePrice .btn span').text(ingosPrice * params.company.programB);
}
But I get an reference error that 'company' variable doesn't exist. How I can use function params as an text reference and part of other variable name?
Thanks