Guest User

Untitled

a guest
Jul 15th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. var simpleDebug = [];
  2. var truthTester = [];
  3.  
  4. // peter here's the logic I was thinking of
  5. // if (arrayOfStates.includes(userAnswer) {
  6. // var included = true && var notIncluded = false;
  7. // }
  8.  
  9.  
  10. function q7() {
  11.  
  12. var arrayOfStates = ['ALASKA', 'ARIZONA', 'ILLINOIS', 'CALIFORNIA', 'WASHINGTON', 'OREGON', 'COLORADO', 'NEVADA'];
  13. var stringOfStates = ('Alaska, Arizona, Illinois, California, Washington, Oregon, Colorado, Nevada');
  14. var userGuess = prompt('Which states have I lived in?').toUpperCase();
  15.  
  16. var trysLeft = 6;
  17. //peter we want to default to false.
  18. var correctness = false;
  19. //I copied and pasted this here, from line 163.
  20. // peter i'm not
  21. var x = 0;
  22.  
  23.  
  24. while (trysLeft > 0) {
  25. if (arrayOfStates.includes(userGuess) ){
  26. var included = true;
  27. var notIncluded = false;
  28. correctness = true;
  29. truthTester.push(correctness);
  30. var x = 1;
  31. trysLeft --;
  32. simpleDebug.push(x);
  33. // 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.
  34. alert('Here are all of the states I\'ve lived in!\n ' + stringOfStates);
  35. // 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.
  36.  
  37. // // 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.
  38. return included;
  39. // break;
  40.  
  41. // so here we want the !== logic
  42. // pseudo code if arrayOfStates !== includ userGuess then {}
  43.  
  44.  
  45. }
  46. else if (notIncluded === false) {
  47. alert('you got it wrong message' + ' this many guess left ' + trysLeft);
  48. }
  49. }
  50. // }else if (/* what logic goes here */ ) {
  51. // trysLeft --;
  52. // truthTester.push(correctness);
  53. // var j = 1;
  54. // simpleDebug.push(j);
  55. // alert('you got it wrong message' + ' this many guess left ' + trysLeft);
  56. // return false;
  57. // }
  58. // break; //we should return instead at this point.
  59. // else {
  60. // alert('invalid input try again');
  61. // };
  62.  
  63. }
  64. q7();
Add Comment
Please, Sign In to add comment