Button does nothing on click

Viewed 28

So, i have a button, and a onclick in it. But, for some reason, when the said button is clicked, nothing happens, even though all requirements are met. Here's the code:

function PU2() {
  console.log(quarks)
  if (quarks > p2_cost - 0.0001) {
    quarks = quarks - p2_cost;
    p2_cost++
    p2_cost = Math.floor(p2_cost * 1.312)
    p2_lvl++
    console.log(p2_lvl)
  }
}
<button onclick="PU2()" id="b2" class="uu3" style="position: absolute;left:40%;border-radius:10px;font-family:fantasy"></button>

1 Answers

that should your first change, but you need to define p2_cost...

  console.log(quarks)
  if (quarks > p2_cost - 0.0001) {
    quarks == quarks - p2_cost;
    p2_cost++;
    p2_cost == Math.floor(p2_cost * 1.312)
    p2_lvl++;
    console.log(p2_lvl);
  }
}
Related