Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

90
Vistas
Multiplying changing variables in javascript and displaying

I'm trying to make the CPS Total: display the current total amount of Shacks multiplied by the value of the ShackOut value. Can somebody please help me achieve this? In this case, the base value of CPS Total should be 0 but should increase by 1 for each Shack purchased (by clicking the button). This number should update

<html>
<head>
  <script>
var Cash = 75;
var CPStot = 0;

var ShackCost = 50;
var Shack = 0;
var ShackTot = 0;
var ShackTotCost1 = 50;
var ShackOut = 1;

function buyShack() {
  if (Cash >= ShackCost) {
    Cash = Cash - ShackCost;
    Shack = Shack + 1;
    ShackCost = Math.round(ShackCost * 1.05);
    ShackCount = Shack;
    ShackTotCost1 = ShackCost;

    document.getElementById("Cash").innerHTML = Cash;
    document.getElementById("ShackTot").innerHTML = ShackCount;
    document.getElementById("ShackTotCost").innerHTML = ShackTotCost1;
  }
}

setInterval(function() {
  Cash = Cash + Shack * ShackOut;
  document.getElementById("Cash").innerHTML = Cash;
}, 250);
  </script>
</head>

<body>
  <h1>
    Shacks: <span id="ShackTot">0</span><br> Cash: <span id="Cash">75</span><br>
    <button onclick="buyShack()" id="button">Click Me!</button><br> CPS Total: <span id="CPStotStart">0</span>
  </h1>
</body>
</html>
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda