-
Notifications
You must be signed in to change notification settings - Fork 0
Checkpoint1 #7
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
base: gh-pages
Are you sure you want to change the base?
Checkpoint1 #7
Conversation
| function mastermind(guess) { | ||
| if (guess === generatedCode) { | ||
| console.log('You win!'); | ||
| return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to return your "win" statement here, instead of just console logging here.
See line 161 to test instructions.
| if (gueArray[3] === genArray[3]) { | ||
| positionCounter+=1; | ||
| } | ||
| console.log('you have '+positionCounter+' letters in the correct position'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return statement here showing correct letters and correct letter locations.
| console.log('you have '+counter+' correct letters'); | ||
|
|
||
| let positionCounter=0; | ||
| if (gueArray[0] === genArray[0]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consolidate lines 121-132 using a for loop and indexof() to check your guess against solution.
|
|
||
| for(let i = 0; i < gueArray.length;i++) | ||
| { | ||
| for(let j=0; j < genArray.length;j++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You only need one loop here.
| for(let j=0; j < genArray.length;j++) | ||
| { | ||
| if (gueArray[i]===genArray[j]) | ||
| counter+=1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also use ++ here to increment by one.
| gameCounter+=1; | ||
| if (gameCounter > 10) { | ||
| console.log("GAME OVER!!") | ||
| return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove empty return statements from your code.
Checkpoint Rubric
This is the rubric that your instructor will use to grade your checkpoints. Please do not edit.
Checkpoint 1
Checkpoint 2
Checkpoint 3