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 Loops, Arrays and Objects Tracking Multiple Items with Arrays Build a Quiz Challenge, Part 1 Solution

hi my program is not working. the correct answer it not increase.

i cant figure out why mine is not working, plz help.

https://teamtreehouse.com/workspaces/28853412

Balazs Peak
Balazs Peak
46,160 Points

Sorry, your link is unreachable :(

3 Answers

Balazs Peak
Balazs Peak
46,160 Points

I've noticed one part of this code which is possibly causing error.

The for loop's repeater variable needs to be declared ("var" keyword?), at least in languages that I'm aware of.

NOT

for (i=0; i< data.length;...... etc

BUT

for (var i=0; i< data.length;...... etc

i still can open this . here is my code:

var corectAnswer= 0; var response; var answer; var question; var resut;

function print(message) { document.write(message); }

var data = [ ['1+1','2'], ['2+3','5'], ['4x1','4'], ['2+4','6']
]

for (i=0; i< data.length; i+=1) {

// pull the array out
question = data[i][0]; answer = data[i][1]; response = parseInt(prompt(question));

//cheack correct answer if (response === answer) { corectAnswer += 1; }
}

resut= "Number of correct answer: " + corectAnswer; print(resut);

Hi all,

I was also having trouble with this challenge (part 1). I found myself messing around with the code and found a much better and simpler way to execute this challenge (for me at least). This is for anyone who is having trouble as I did. Check the link below; https://teamtreehouse.com/workspaces/30078332#

If there are any problems, let me know.