Hi Everyone.I started learning javaScript few days ago

Am finding it difficult solving step 76 . Please here is my code below:

const gold = 0;

  if (gold >= 10) {
    console.log();
  }
  

step 76 of what? can you give more details?

The requirement says the following:

Start by placing all of the code in your buyHealth function inside an if statement. For the if statement condition, check if gold is greater than or equal to 10.

Go to the buyHealth function and add the if condition there. The buyHealth function already has the following:

function buyHealth() {
/* place all these statements inside an if condition */
  gold -= 10;
  health += 10;
  goldText.innerText = gold;
  healthText.innerText = health;

}

I have added a comment to guide you.

I just did that but my code is yet to pass.

Here is my current code:

function buyHealth() {
 if () {
  gold -= 10;
  health += 10;
  goldText.innerText = gold;
  healthText.innerText = health;



  
    
  }

That’s a good try.
Now you need to take care of what to place inside the if condition. The requirement says:

[In] the if statement condition, check if gold is greater than or equal to 10.

That means that something must be inside the parenthesis of the if

1 Like

I added it but still having some problems.
my code below:

function buyHealth() {
 if (gold >= 10) {
  gold -= 10;
  health += 10;
  goldText.innerText = gold;
  healthText.innerText = health;



  
    
  }

Ok, now the test probably will not succeed because there’s a missing curly bracket that would close the if condition or the function. Look at the correction.

function buyHealth() {
  if (gold >= 10) {
    gold -= 10;
    health += 10;
    goldText.innerText = gold;
    healthText.innerText = health;
  }
}

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.