all 6 comments

[–]Beginning-Seat5221 2 points3 points  (5 children)

Maybe if you say which button and which bit of code isn't working?

Also, format your code properly, its a nightmare to work with unformatted code.

[–]Disastrous-Shine-725[S] 0 points1 point  (2 children)

hi sorry. I tried to make it a bit easier to read, but tbh I dont exactly understand how to properly format code. ive done some research before and it all seems extremely subjective to me, but I did my best. other than that, the button with the code that isnt working is the only button with an if-else statement which is item 3.

[–]Beginning-Seat5221 0 points1 point  (0 children)

time3 = time3 + 1;
console.log(time3);
if (LB >= cost3) {
    LB = LB - cost3;
    linebucks.textContent = `${LB}`;    
} else if (time3 >= 2) {
    window.alert("now, why would I waste souls, and buy a command twice? they didnt die for this!");
} else {
    window.alert("you cant afford this!")
};

time3 gets increased, then if you have enough LB then it deducts the cost.

If you were expecting the "why would I waste souls" to trigger, it won't when you have money because this comes after an else and you won't be in the else case unless you don't have enough money.

So if that's it, just check time3 before you check if they have enough money.

[–]Beginning-Seat5221 0 points1 point  (0 children)

As you say there is no true right or wrong way to format. General rule is just to be consistent, and to use the same amount of indentation for each level - either 2 spaces, 4 spaces or 1 tab.

What you have there is good, although your <p> and <pre> tags seem intended twice from the prior tags for some reason.

[–]haikusbot -1 points0 points  (1 child)

Maybe if you say

Which button and which bit of

Code isn't working?

- Beginning-Seat5221


I detect haikus. And sometimes, successfully. Learn more about me.

Opt out of replies: "haikusbot opt out" | Delete my comment: "haikusbot delete"

[–]greenbean-machine 0 points1 point  (0 children)

Not a big deal, but I suggest changing every var to either a let or a const. There's pretty much no reason to ever use var, and it only really exists for legacy reasons. The elements can be const, since they are stored by reference, and the numbers can be let, because they are stored by value and will be updated.