Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Jonathan Hull
Jonathan Hull
5,606 Points

Hi, is there a way to terminate the program based on an initial question.

var start = prompt("Hello! Are you ready to play a game?");
var correct = 0;
var yes = false;

if (start.toLowerCase() === "yes") {
yes = true;
} else {
    yes= false;
}

if (yes = false) { 
    document.write("We are done here");
} 

then the rest of the code.

I can get the program to spit out the we are done here part, but the rest of the program still runs.

Thanks

1 Answer

andi mitre
STAFF
andi mitre
Treehouse Guest Teacher

Hey Jonathan, your else statement is not needed because the variable yes is set to false to start with. Try this:

var start = prompt("Hello! Are you ready to play a game?");
var correct = 0;
var yes = false;

if (start.toLowerCase() === "yes") {
  yes = true;
} 

if (yes == false) { 
    document.write("We are done here");
}