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

Matthew Egginton
Matthew Egginton
2,754 Points

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!