Hice un simple juego de botón +1:
var money = 0; function addOne() { money++; document.getElementById("money").innerHTML = money; } window.setInterval(function(){ if(document.getElementById("money").innerHTML >= "50"){ document.getElementById("timesTwoButtonShop").disabled = false; } else { document.getElementById("timesTwoButtonShop").disabled = true; } }, 1); * { margin: 0; padding: 0; font-family: 'Roboto', sans-serif; } <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet"> <p>Money: <b id="money">0</b><b>$</b></p> <button onclick="addOne();">+1$</button> <br><br> <h1>Shop</h1> <button id="timesTwoButtonShop">2x for 50$</button> Lo hice para que si el dinero supera los cincuenta, se habilitará el botón 2x for 50$ . Pero cuando el dinero está entre $ 6 y $ 9, el botón está habilitado de alguna manera. Realmente no sé cómo arreglar esto.
Gracias de antemano y que tengas un buen día.
Agregue un parseInt para que no sea una comparación de cadenas O use money que ya es un int
var money = 0; function addOne() { money++; document.getElementById("money").innerHTML = money; } window.setInterval(function(){ // if (money>=50) { if(parseInt(document.getElementById("money").innerHTML) >= 50){ document.getElementById("timesTwoButtonShop").disabled = false; } else { document.getElementById("timesTwoButtonShop").disabled = true; } }, 1); * { margin: 0; padding: 0; font-family: 'Roboto', sans-serif; } <link rel="preconnect" href="https://fonts.googleapis.com"> <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet"> <p>Money: <b id="money">0</b><b>$</b></p> <button onclick="addOne();">+1$</button> <br><br> <h1>Shop</h1> <button id="timesTwoButtonShop">2x for 50$</button>