keith85 0 Newbie Poster

I have a little problem here. I know its one of those easy things that is leaving me scratching my head, but I just can't figure it out. The homework assignment is to create a guess game. The user has to guess last year's best motion picture (The King's Speech in this case). For every letter the user has correct, display the letter while displaying an asterisk for the character(s) that is wrong. I used nested for loops to try to accomplish this, but the first character only comes out right. I know its something simple, I tried my best, but any help would be appreciated. Thanks.

var arrAnswer = new Array('T', 'h', 'e', ' ', 'K', 'i', 'n', 'g', '\'', 's', ' ', 'S', 'p', 'e', 'e', 'c', 'h');

var arrGuess = new Array('T', 'h', 'e', ' ', 'K', 'i', 'n');

var arrBuildString = new Array();

var intInnerCount = 0;

var intOuterCount = 0;

for(var i = 0; i < arrAnswer.length; i++)

	// Test variable to see how many times the outer loop
	// has been hit.


	for(var j = 0; j < arrGuess.length; j++)

		// Test variable to see how many times the inner loop
		// has been hit.


		// Determine if the strings are equal.
		// If both strings are equal, then write the letter
		// to let the user know that their guess was correct.

		if(arrGuess[j] == arrAnswer[i])











// Print the result.

for(var i = 0; i < arrBuildString.length; i++)




// Display the test variables.

//document.write("The inner loop was called " + intInnerCount + " times." + "<br />");

//document.write("The outer loop was called " + intOuterCount + " times.");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.