Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements The Conditional Challenge

Jerrod Quintana
Jerrod Quintana
2,734 Points

Why won't my program run? Is it a bug?

var answer1 = prompt ("What is 2 +3?");
var answer2 = prompt ("What is the greatest country in the world?");
var answer3 = prompt ("What planet are you on?");
var answer4 = prompt ("Do you believe in aliens?");
var answer5 = prompt ("Is mass effect an incredible game?");

this is what I have in my program, just the start but when I save and try to preview the exercise, nothing happens. The page pops up but no prompts. I've saved, tried just doing one, just doing an alert, checking the script src in the html file, yet nothing. What's wrong here, could this just be a bug?

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

What happens if you try just one from the developer's tools console? Do you get a popup then?

2 Answers

Hey Jerrod,

Can you post your code for your HTML file?

Jerrod Quintana
Jerrod Quintana
2,734 Points

I don't think so, my computer gives me some trouble with treehouse, I think this has to just be a bug

Omar Farag
Omar Farag
4,573 Points

Ye, I have the same problem with this code:

alert("Here we go");
var agree = prompt("Are you ready?");
var totalScore = score1 + score2 + score3 + score4 + score5; 
var score1 = 0;
var score2 = 0;
var score3 = 0;
var score4 = 0;
var score5 = 0;
console.log("Variable created");
if ( agree.toUpperCase() === "Y" || agree.toUpperCase() === "YES") {
  // Quiz code
  alert("You have five questions. Lets go!");
  // First Question
  var qstn1 = prompt("What  programming language is used to build the skeleton of webpages?");
  if ( qstn1.toUpperCase() === "HTML") {
  alert("Well done!");
    score1 = 1;
  } else {
  alert("Sorry, that was incorrect");
  }

  //Second Question
  var qstn2 = prompt("What programming language is used to STYLE(<=hint) webpages?");

  if (qstn2.toUpperCase() === "CSS") {
  alert("Wow! Not bad!");
    score2 = 1;
  } else {
  alert("Nice try, but that wasn't it. Better luck next time.");
  }

  //Third question
  var qstn3 = prompt("What programming language is used to add functionality to a webpage(Smells like coffee...)");

  if (qstn3.toUpperCase() === "JAVASCRIPT") {
  alert("Nice. Have you tried Java?");
    score3 = 1;
  } else {
  alert("Bummer! Better luck next time!");
  }

  //Fourth Question
    var qstn4 = prompt("Is there a difference between 'Java' and 'JavaScript'? ");

  if (qstn4.toUpperCase() === "YES") {
  alert("Wow. You know your languages..");
    score4 = 1;
  } else {
  alert("Sorry. Though they both have similair names, they aren't the same languages.");
  }

  //Fifth Question
    var qstn5 = prompt("How many questions have you taken this quiz?");

  if (qstn5.toUpperCase() === "5") {
  alert("Nice thinking!");
    score5 = 1;
 } else {
  alert("Sorry, it was a trick question. You actually took 5 questions, including the one you just answered.");
  }

  //Score Count
  if (totalScore === 5) {
    alert("Your got it perfect! Take this virtual gold crown. [5/5 answered correctly]");
   } else if (totalScore >= 3) {
   alert("Nice job! Maybe next time you'll get it all correctly. You get a silver crown. [" + totalScore + "/5 answered correctly]");
   } else if (totalScore === 2) {
   alert("Looks like your a beginner at web develepment. Don't worry. You'll learn it eventually. Take this bronze crown. [" + totalScore + "/5 answered correctly]);
   } else if (totalScore === 1) {
   alert("Better luck next time! You get a wooden crown. [" + totalScore + "/5 answered correctly]");
    } else if (totalScore === 0) {
    alert("Ouch. You didn't get anything correct. Are you a web developer? Unfortunately, you don't get a crown. [" + totalScore + "/5 answered correctly]
    }



  } else {
alert("Okay. Refresh the page if you change your mind.");
}