So what I'm trying to do is convert a series of functions like:
function classAClickSell(){
if (classASupply>=1) {
cash = cash + classAValue;
document.getElementById("cash").innerHTML = cash;
classASupply = classASupply - 1;
document.getElementById("classASupply").innerHTML = classASupply;
};
};
function classBClickSell(){
if (classBSupply>=1) {
cash = cash + classBValue;
document.getElementById("cash").innerHTML = cash;
classBSupply = classBSupply - 1;
document.getElementById("classBSupply").innerHTML = classBSupply;
};
};
and am trying to get them all to resemble something more along the lines of:
function ClickSell(class){
if (class.concat('Supply') >= 1) {
cash = cash + class.concat('Value');
document.getElementById("cash").innerHTML = cash;
class.concat('Supply')--;
document.getElementById(class.concat('Supply')).innerHTML = class.concat('Supply');
}
}
and I was wondering if there is a way to do this, I can't seem to find one. If anyone can help out or point me in the right direction I will be stocked.