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 trialTina Budzáková
6,685 PointsWhy the questions are not popping up?
This is my code and the questions are not even popping up. Why?
const questions = [["What is the capital city of France?", "Paris"],
["What is the capital of Spain?", "Madrid"],
["What is the capital of Slovakia?", "Bratislava"]
];
let correctAnswers = 0;
for (let i = 0; i < questions.lenght; i++) { let question = questions[i][0]; let answer = questions[i][1]; let response = prompt(questions);
if (response === answer) { correctAnswers += 1; } }
let html = <h1>You guessed ${correctAnswers} question(s).</h1>
;
document.querySelector("main").innerHTML = html;
1 Answer
Joseph Yhu
PHP Development Techdegree Graduate 48,638 Points- You have a typo: for (let i = 0; i < questions.lenght; i++)
- This should just be question, not questions: prompt(questions);
- This, <h1>You guessed ${correctAnswers} question(s).</h1>, should be surrounded by backticks.
Tina Budzáková
6,685 PointsTina Budzáková
6,685 PointsGot it. Thank you!