Your if statement should check if gold is greater than or equal to 10
How do I have it so then my ‘if’ statement checks if ‘gold’ is greater than or equal to ‘10’??
Your code so far
WARNING
The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.
You will need to take an additional step here so the code you wrote presents in an easy to read format.
Please copy/paste all the editor code showing in the challenge from where you just linked.
Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Challenge Information:
Learn Basic JavaScript by Building a Role Playing Game - Step 76
function buyHealth() {
if (num >= 10) {
gold -= 10;
health += 10;
goldText.innerText = gold;
healthText.innerText = health;
console.log("This code will run because num is greater than or equal to 10.")
}
}
function buyHealth() {
if (num >= 10) {
gold -= 10;
health += 10;
goldText.innerText = gold;
healthText.innerText = health;
console.log(“This code will run because num is greater than or equal to 10.”)
}
}
If you console.log(num) inside of that buyHealth() function, you will probably get undefined because of what Ilenia is illuding to. Is there another variable name you should be checking if its greater or less than 10?
It is great that you solved the challenge, but instead of posting your working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.
We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.
Jeremy can you suggest an alternative way of helping him get to this answer? We all took the steps to help this person get here. And we blocked the answer using Spoilers and even did not directly expose the entire solution to the forum. Instead we took steps to gently guide the user to the solution.