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