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 Making Decisions in Your Code with Conditional Statements The Conditional Challenge Solution

Conditional coding challenge question. (Unit 1??)

Good evening. I got some great help and now have three out of 5 prompts working, but program kicks me out and will not run the last 2 prompts for some reason. As always any and all help appreciated.

Code is located on Github here: https://github.com/Aikitiger/Coding-challenges/blob/main/Conditional%20Challenge

I have tried running it in Google Chrome console as well as repl.it, Getting the following errors:

ReferenceError: document is not defined at /home/runner/aryz0vaezqe/index.js:11:14 at Script.runInContext (vm.js:130:18) at Object.<anonymous> (/run_dir/interp.js:209:20) at Module._compile (internal/modules/cjs/loader.js:1137:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10) at Module.load (internal/modules/cjs/loader.js:985:32) at Function.Module._load (internal/modules/cjs/loader.js:878:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47Hint: hit control+c anytime to enter REPL. 

2 Answers

You are missing prompt in questions 4 and 5 :

const answerFour = ("Should Ted Cruz have stayed in Cancun?");
if (answerFour.toUpperCase() === 'YES') {
    answer += 1;

should read :

const answerFour = prompt("Should Ted Cruz have stayed in Cancun?");
if (answerFour.toUpperCase() === 'YES') {
    answer += 1;

Thank you Matthew Egginton!