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 Arrays Multidimensional Arrays Build a Quiz Challenge – One Solution

Naoki Yoshida
Naoki Yoshida
6,984 Points

My answers are strings. ".toLowerCase" doesn't work.

My answers to the questions are strings type values. In the "if" statement, in the conditional part, when I add to the response variable ".toLowerCase", all the iterations result in false even when I answer the prompt correctly. Why is happening this? Please Help!

let questions = [
  ["Where is my mind?","in one place"],
  ["What drives humans?","love"],
  ["Are you happy?","yes"]

let correctAnswers = 0

 for (let i = 0; i < questions.length; i++) {
   let submit = prompt(questions[i][0]);
   if (submit.toLowerCase === questions[i][1]) {

document.querySelector('main').innerHTML = `You answered correctly ${correctAnswers} questions.`;

1 Answer

Tony Idehen
Tony Idehen
8,058 Points

Check the toLowerCase() I think it needs brackets.