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 Question Validator #1

Open
kySuga opened this issue Sep 25, 2022 · 0 comments
Open

Add Question Validator #1

kySuga opened this issue Sep 25, 2022 · 0 comments

Comments

@kySuga
Copy link
Owner

kySuga commented Sep 25, 2022

Function is loosely laid out (and commented out) currently in main. js; also found below.

// Function that validates question
function validateQuestion() {
  const validYesNoQuestions = [
    'am',
    'are',
    'aren\'t',
    'can',
    'can\'t',
    'could',
    'couldn\'t',
    'did',
    'didn\'t',
    'do',
    'does',
    'doesn\'t',
    'don\'t',
    'if', // added for a 'if..., will...?' question
    'is',
    'isn\'t',
    'had',
    'hadn\'t',
    'has',
    'hasn\'t',
    'have',
    'haven\'t',
    'may',
    'might',
    'must',
    'ought',
    'should',
    'shouldn\'t',
    'was',
    'were',
    'weren\'t',
    'will',
    'won\'t',
    'would',
    'wouldn\'t'
  ]

  // searches inside of validYesNoQuestions
  const question = validYesNoQuestions.some();
  const i;

  for (i = 0; i < question; i++) {}

  // if else 
  if (question.toLowerCase() == validYesNoQuestions.toLowerCase()) {
    clickSubmitQuestion();
  } else {
    alert('Please ask the Magic Eight Ball a valid Yes or No question');
  }

  return false;
}
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

1 participant