Share your repls and programming experiences

← Back to all posts
💻A great Hack the world idle game💻
ItsEmpCs (37)

Basically like any idle game. Click to earn money and buy stuff to win the game, recommend to open in new tap!!! Also thx to @mat1 for helping on some of the codes!!! Upvote if you like this game!!!

Commentshotnewtop
AidenWaterman (0)

It's great, but it logs errors because there's no elements with the ids nextCost1 or nextCost2.
here I've commented out the bad lines

function BuySeniorHacker() {
  var SeniorCost = Math.floor(100 * Math.pow(1.2, Senior));
  if (Hacked >= SeniorCost) {
    Senior = Senior + 1;
    Hacked = Hacked - SeniorCost;
    HackPerClick = HackPerClick + 5;
    document.getElementById("Senior").innerHTML = Senior;
    document.getElementById("InfoHacked").innerHTML = Hacked;
    localStorage.setItem("Hacked", Hacked);
    localStorage.setItem("HackPerClick", HackPerClick);
    localStorage.setItem("Senior", Senior);
  }
  var nextCost1 = Math.floor(100 * Math.pow(1.2, Senior));
  document.getElementById("SeniorCost").innerHTML = nextCost1;
  //document.getElementById("nextCost1").innerHTML = SeniorCost;
  localStorage.setItem("nextCost1", nextCost1);
  localStorage.setItem("SeniorCost", SeniorCost);
}
function BuyProHacker() {
  var ProCost = Math.floor(1000 * Math.pow(1.2, Pro));
  if (Hacked >= ProCost) {
    Pro = Pro + 1;
    cps = cps + 5;
    HackPerClick = HackPerClick + 10;
    Hacked = Hacked - ProCost;
    document.getElementById("Pro").innerHTML = Pro;
    document.getElementById("InfoHacked").innerHTML = Hacked;
    localStorage.setItem("Hacked", Hacked);
    localStorage.setItem("Pro", Pro);
    localStorage.setItem("HackPerClick", HackPerClick);
    localStorage.setItem("cps", cps);
  }
  var nextCost2 = Math.floor(1000 * Math.pow(1.2, Pro));
  document.getElementById("ProCost").innerHTML = nextCost2;
  //document.getElementById("nextCost2").innerHTML = ProCost;
  localStorage.setItem("ProCost", ProCost);
  localStorage.setItem("nextCost2", nextCost2)
}
AidenWaterman (0)

@AidenWaterman
and another error

function Nb() {
  if (Hacked > 100000){
  Hacked = Hacked - 100000;
  c = c - 1;
  HackPerClick = HackPerClick + 100;
  Nbc = 1;
  localStorage.setItem("Hacked", Hacked);
  localStorage.setItem("c", c);
  //localStorage.setItem("HackPerClick"); // error was here
  localStorage.setItem("HackPerClick", HackPerClick);// replace with this
  localStorage.setItem("Nbc", Nbc);
  }
  document.getElementById("InfoHacked").innerHTML = Hacked;
  document.getElementById("c").innerHTML = c;
}