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 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!