Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var simpleDebug = [];
- var truthTester = [];
- // peter here's the logic I was thinking of
- // if (arrayOfStates.includes(userAnswer) {
- // var included = true && var notIncluded = false;
- // }
- function q7() {
- var arrayOfStates = ['ALASKA', 'ARIZONA', 'ILLINOIS', 'CALIFORNIA', 'WASHINGTON', 'OREGON', 'COLORADO', 'NEVADA'];
- var stringOfStates = ('Alaska, Arizona, Illinois, California, Washington, Oregon, Colorado, Nevada');
- var userGuess = prompt('Which states have I lived in?').toUpperCase();
- var trysLeft = 6;
- //peter we want to default to false.
- var correctness = false;
- //I copied and pasted this here, from line 163.
- // peter i'm not
- var x = 0;
- while (trysLeft > 0) {
- if (arrayOfStates.includes(userGuess) ){
- var included = true;
- var notIncluded = false;
- correctness = true;
- truthTester.push(correctness);
- var x = 1;
- trysLeft --;
- simpleDebug.push(x);
- // peter and we don't just want to alert a string, we also want to alert the whole arrayOfStates. So we should alert a string and that array together.
- alert('Here are all of the states I\'ve lived in!\n ' + stringOfStates);
- // peter I didn't use any breaks in mine, and it worked, when I did mess around with break it broke my code, so we should be careful with that.
- // // peter it looks like the way i handled it was having a neighbor else statement (by neighbor i mean they are not nested!) that handles all other possibilites.
- return included;
- // break;
- // so here we want the !== logic
- // pseudo code if arrayOfStates !== includ userGuess then {}
- }
- else if (notIncluded === false) {
- alert('you got it wrong message' + ' this many guess left ' + trysLeft);
- }
- }
- // }else if (/* what logic goes here */ ) {
- // trysLeft --;
- // truthTester.push(correctness);
- // var j = 1;
- // simpleDebug.push(j);
- // alert('you got it wrong message' + ' this many guess left ' + trysLeft);
- // return false;
- // }
- // break; //we should return instead at this point.
- // else {
- // alert('invalid input try again');
- // };
- }
- q7();
Add Comment
Please, Sign In to add comment