Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a winning Message #22

Open
IsuruAbeyrathna opened this issue Dec 20, 2020 · 2 comments
Open

Add a winning Message #22

IsuruAbeyrathna opened this issue Dec 20, 2020 · 2 comments

Comments

@IsuruAbeyrathna
Copy link

Please can someone says how to add a winning message after the puzzle completed?
Thank you!

@bradzo
Copy link

bradzo commented Feb 27, 2021

Try this:

After the checkAnswer: function(e) ... about line 303:

Add this: (usinjg underscore _uniq function

						// ADDED! check the solved array against the original puzzle data entries
						var uniqSolved  = _.uniq(solved);
						console.log(uniqSolved);
						var numMatches = 0;
						var numMatchedAll = 0;
						for(var i=0; i < puzz.data.length; i++) {		// look through all entries
							numMatchedAll++;
							for(var a=0; a < solved.length; a++) {
								var puzzItem = puzz.data[i];
								var puzzAnswer = uniqSolved[a];
								if(puzzAnswer === puzzItem.answer) {
									numMatches++;
								}
							}
						};
						if(numMatches === numMatchedAll) {
							console.log("puzzle solved!!!!!!!");
						} else {
							console.log("not yet ...");
						}
						

Up to you what to do when puzzle solved

@IsuruAbeyrathna
Copy link
Author

Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants