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 trialNaoki Yoshida
6,984 PointsMy 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]) {
correctAnswers++
}
}
document.querySelector('main').innerHTML = `You answered correctly ${correctAnswers} questions.`;
Naoki Yoshida
6,984 PointsNaoki Yoshida
6,984 PointsThanks! Tony Idehen, it was that typo !