0

This is my JSFiddle to the incremental game: https://jsfiddle.net/y69sh3nc/

I have the function getAutoClicker()

var AutoClickers = 0;
var AutoClickerCost = 10;   

function getAutoClicker(){
   if(cookieClicks >= AutoClickerCost){
       AutoClickers++;
       cookieClicks -= AutoClickerCost;
       AutoClickerCost += Math.floor(AutoClickerCost*.3);
   } else{
       alert("Oh No!  It appears you do not have enough cookies to purchase an Auto Clicker.  An Auto Clicker currently costs "+AutoClickerCost+" which is "+(AutoClickerCost-cookieClicks)+" more cookies than you have.")
   }
}

I don't want to write another function for getAutoClickerTwo() because I don't want to repeat myself.

How can I write a function and use it for as many auto clickers as I want?

When I try to write a general function and call it with different paramenters for each button it does not work since the variables won't update in the other functions.

Light_Warrior
  • 183
  • 1
  • 4
  • 17

0 Answers0