title: How to use decimals (0.01) in Javascript function
body: <p>I want to make this project: codepen.io/samuelbeard/pen/Dsdie, to where when you upgrade, it will increment to 0.01 Click Per Second Automatically, instead of 1 click per second. I am pretty sure this has to do with a function, but I am a beginner and cant find anything to change it, and dont have the knowledge. Is there a variable I have to change, or what?</p>
  <p>Here are some variables I have so far, but the code might be more helpful to see:</p>
  <pre><code>//variables
  var clicks = 0; //increment this by one every click
  var auto_clicks = 0; //automatically click once per second
  var cost = 1; //the cost of this should increase exponentially
  var upgrade_speed = 0; //the level of the speed up upgrade
  var click_rate = 1000; //ms between each autoclick
  var interval_auto; //storing our interval here so we can update it
  var click_increment = 1; //how many clicks per click
  //functions
  
  function update_total_clicks() { //updates the number of clicks   
      var e = document.getElementById(&quot;total_clicks&quot;);
      e.innerHTML = clicks;
  }
  
  function buy_something(c, button) {
      if (clicks &lt; c) {
          button.className = 'btn btn-danger';
          setTimeout(function() {
              var e = document.getElementsByClassName(&quot;btn-danger&quot;)[0];
              e.className = 'btn btn-success';
          }, 1000);
          return false;
      }
      clicks -= c;
      return true;
  }
  
  function update_workers() {
      var e2 = document.getElementById(&quot;time_period&quot;);
      e2.innerHTML = parseFloat(click_rate / 1000.0).toFixed(2);
      clearInterval(interval_auto);
      interval_auto = setInterval(function() {
          clicks += auto_clicks;
          update_total_clicks();
      }, click_rate);
  }
  //click events
  document.getElementById(&quot;click&quot;).onclick = function() {
      clicks = parseFloat(clicks) + parseFloat(click_increment);
      update_total_clicks(); //updates the text
  };
  document.getElementById(&quot;buy_click&quot;).onclick = function() {
      if (!buy_something(cost, this)) return;
      auto_clicks++;
      cost = Math.pow(2, auto_clicks); //new cost
      update_total_clicks();
      var e = document.getElementById(&quot;clicks_per_second&quot;);
      e.innerHTML = auto_clicks;
      var e2 = document.getElementById(&quot;buy_click&quot;);
      e2.innerHTML = 'Buy for ' + cost;
      var e2 = document.getElementById(&quot;autoclicker_level&quot;);
      e2.innerHTML = 'lvl  ' + auto_clicks;
  };
  document.getElementById(&quot;upgrade_speed&quot;).onclick = function() {
      var upgrade_cost = (Math.pow(3, upgrade_speed)) * 100;
      if (!buy_something(upgrade_cost, this)) return;
      upgrade_speed++;
      click_rate = click_rate * 0.90;
      update_workers();
      var e2 = document.getElementById(&quot;upgrade_speed&quot;);
      e2.innerHTML = 'Buy for ' + ((Math.pow(3, upgrade_speed)) * 100);
      var e2 = document.getElementById(&quot;speed_level&quot;);
      e2.innerHTML = 'lvl  ' + upgrade_speed;
  };
  
  //Increase Click Increment
  document.getElementById(&quot;increase_clicks&quot;).onclick = function() {
      var upgrade_cost = (Math.pow(3, click_increment)) * 1;
      if (!buy_something(upgrade_cost, this)) return;
      click_increment++;
      update_workers();
      var e2 = document.getElementById(&quot;click_increment&quot;);
      e2.innerHTML = 'Buy for ' + ((Math.pow(3, click_increment)) * 100);
  };
  
  //Start Autoclickers
  update_workers();
  
  function set_cookie(cookie_name, value) {
      expiry = new Date();
      expiry.setTime(new Date().getTime() + (10 * 60 * 1000));
      var c_value = escape(btoa(JSON.stringify(value))) + &quot;; expires=&quot; + expiry.toUTCString();
      document.cookie = cookie_name + &quot;=&quot; + c_value;
  }
  
  function get_cookie(cookie_name) {
      var c_value = document.cookie;
      var c_start = c_value.indexOf(&quot; &quot; + cookie_name + &quot;=&quot;);
      if (c_start == -1) {
          c_start = c_value.indexOf(cookie_name + &quot;=&quot;);
      }
      if (c_start == -1) return false;
      c_start = c_value.indexOf(&quot;=&quot;, c_start) + 1;
      var c_end = c_value.indexOf(&quot;;&quot;, c_start);
      if (c_end == -1) {
          c_end = c_value.length;
      }
      c_value = atob(unescape(c_value.substring(c_start, c_end)));
      return JSON.parse(c_value);
  }
  </code></pre>
  <p>Thanks,
  Peter</p>