Dragon Slayer! Removal of the "false" in the log...is it possible/how?


I was hoping to remove the false from hitting the log.  Can it be done? 

var slaying = true;
// A bit of new math magic to calculate the odds
// of hitting the dragon. We'll cover this soon!
var youHit = Math.floor(Math.random() * 2);
var damageThisRound = Math.floor(Math.random() * 5 + 1);
var totalDamage = 0;

while (slaying) {
  if (youHit) {
    console.log("You hit the dragon and did " + damageThisRound + " damage!");
    totalDamage += damageThisRound;
    if (totalDamage >= 4) {
      console.log("You did it! You slew the dragon!");
      slaying = false;
    } else {
      youHit = Math.floor(Math.random() * 2);
  } else {
    console.log("The dragon burninates you! You're toast.");
    slaying = false;


Hm... i tried your code on jsbin(press the run button in the top right), seems to be fine? I don't have a in-depth understanding of consoles, but in most cases false shouldn't be printed to the console


not sure why the codecademy console has the behaviour it has.
jsbin is just a site where you can run code


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