Why does 'false' show up on the console every time I run this program?


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/javascript-beginner-en-mrTNH-6VIZ9/0/6?curriculum_id=506324b3a7dffd00020bf661

<In what way does your code behave incorrectly? Include ALL error messages.>
Whenever I hit save&submit code, ‘false’ is displayed on the console. The program works fine, but console.log(“false”) isn’t written anywhere in my code. Why is it showing up and how do I hide it?

```

var slaying = true
var youHit = Math.floor(Math.random() * 2)
var damageThisRound = Math.floor(Math.random() * 5 + 1)
var totalDamage = 0

while(slaying) {
if (youHit === 1) {
console.log(“You shoot the dragon with a pistol.”)
totalDamage = totalDamage += damageThisRound;
if (totalDamage >= 4) {
console.log(“You pwned that dragon n00b.”)
}
else {
youHit
}
}
else {
console.log(“Get rekt”)
};
slaying = false
};

<do not remove the three backticks above>

#2

This is normal behaviour for Javascript; the last defined value of a function or statement (if nothing is returned) is printed to the console for debugging purposes.

In this case, it’s where you have defined slaying = false.