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