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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Edwin Billa](https://uploads.teamtreehouse.com/production/profile-photos/3893122/micro_10445971_1428768804072022_7003223370860012182_n.jpg)
Edwin Billa
Courses Plus Student 6,882 PointsPlease why i am getting this error from the console. "Uncaught TypeError: Cannot read property 'toUpperCase' of null"
// two dimensional array
var setQuestionsAndAnswers = [["What year was 9/11?", "2001"],["What year was Sadam Hussein Killed?", "2006"], ["Who is the 44th President of USA?", "BARACK OBAMA"],["Which year was slavery abolished in USA", "1865"], ["Who invented electricity?","THOMAS EDISON"], ["What is the tallest mountain in the world?", "EVEREST"]]
// Declared 2 arrays to keep track of questions answered correctly and wrongly
var correctlyAnswered = [];
var wronglyAnswered = [];
var answer = "";
// iterating through the array
for ( var i = 0; i < setQuestionsAndAnswers.length; i++) {
answer = prompt(setQuestionsAndAnswers[i][0]);
answer = answer.toUpperCase(); // im trying to change the "answer" to upper case but it won't let me.
/** checking if the "answer" is equal to the second index
in each of the nested arrays or not then i add that questions
to the arrays i declared early respectively" **/
if ( answer === setQuestionsAndAnswers[i][1]) {
correctlyAnswered.push(setQuestionsAndAnswers[i][0]);
}
else if (answer !== setQuestionsAndAnswers[i][1]) {
wronglyAnswered.push(setQuestionsAndAnswers[i][0]);
}
}
2 Answers
![Vittorio Somaschini](https://uploads.teamtreehouse.com/production/profile-photos/740312/micro_Schermata_2014-03-27_alle_14.37.50.png)
Vittorio Somaschini
33,371 PointsHello Edwin,
I have tested the code in my browser's javascript console and it worked. I was able to get to the end and I got a score.
I was even able to check the 2 resulting variables with correct and wrong questions stored.
Vitto
![Vittorio Somaschini](https://uploads.teamtreehouse.com/production/profile-photos/740312/micro_Schermata_2014-03-27_alle_14.37.50.png)
Vittorio Somaschini
33,371 PointsWell I have used Chrome when I tested it so it may be something in your settings?
Not sure though...
Edwin Billa
Courses Plus Student 6,882 PointsEdwin Billa
Courses Plus Student 6,882 PointsHello Vitto, It works fine when i run code on safari browser but when i use google chrome with console i get that error. any reason?