javascriptコードを関数でリファクタリングしたいと思います。別の変数/ javamsのparams内の変数を参照するには?
ingos - 会社の名前ですが、私は同様のコード部分の5番目を持っています。
$('#ingosRegularPrice').removeClass("inactive");
$('#ingosActivePrice').removeClass("inactive");
$('#ingosRegularPrice .btn span').text(ingosPrice);
$('#ingosActivePrice .btn span').text(ingosPrice * params.ingos.programB);
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);
}
のようなもので
しかし、私は「会社の変数が存在しないことを参照エラーを取得します。どのように私はテキスト参照と他の変数名の一部として関数のパラメータを使用することができますか?
おかげ
:へ
。あなたが正しく合格しているかどうかを確認してください –