Learn Basic JavaScript by Building a Role Playing Game - Step 171

Tell us what’s happening:

Should I add a new if or where exactly I check if health is <= to 0

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

 function pick(guess) {
  const numbers = [];
  while (numbers.length < 10) {
    numbers.push(Math.floor(Math.random() * 11));
  }
  text.innerText = "You picked " + guess + ". Here are the random numbers:\n";
  for (let i = 0; i < 10; i++) {
    text.innerText += numbers[i] + "\n";
  }
  if (numbers.includes(guess), heath <= 0) {
    text.innerText += "Right! You win 20 gold!";
    gold += 20;
    goldText.innerText = gold;
    lose();
  } else {
    text.innerText += "Wrong! You lose 10 health!";
    health -= 10;
    healthText.innerText = health;
health <= 0;
 
  }
}

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/119 Version/11.1.1 Safari/605.1.15

Challenge Information:

Learn Basic JavaScript by Building a Role Playing Game - Step 171

Yes, you need to use if statement to check for conditions.

1 Like

Yes but where in the already existing id or a new one the instructions are not precise!!??

Add a New if statement on line number 284. If you reset your challenge, you see a one line space there.
@mohmedyahya833

1 Like

Waw it pass thanks much
I never thought it’s possible to add an if statement inside an else statement