Modern Medicine Through JavaScript

I love a medical school that gives online tests (quizzes, maybe?) and evaluates the results through JavaScript.  I especially love when it uses this logic to do it:

if(correct) return true;
else {
  if(guess < 2) {
    alert("That is not correct.");
    guess = guess + 1;
    return false;
  } else {
    alert("You have guessed incorrectly, but may move on.");
    return true;
  }
}

I hope my (hypothetical) surgeon works the same way.  “You’ve removed three organs.  None of them were right, but you can send him home now anyway.”

3 thoughts on “Modern Medicine Through JavaScript

  1. just pixels says:

    I think you’re misreading the code. The method returns false to allow the student another “guess”. Assuming “correct” is global, rather than local, the caller might read:

    while (!GetAnswer());
    if (correct) score++;

  2. just pixels says:

    Now, having critiqued the code, I must say I’d rather not give my doctor two guesses to diagnose me. TV’s “House” seems to need three guesses with the first two generally being fatally wrong.

    How about this:

    if (!ocrrect) SendToUser(10000 volts);

  3. Ben says:

    What I found disconcerting wasn’t the “return false” but rather the else: “You have guessed incorrectly, but may move on.” It there returns true, indicating a correct answer, and allowing the student to proceed, even though the answer was not correct.

    (I’ve already forgotten the context, but I think “correct” is computed just above this snippet.)

Leave a Reply

Your email address will not be published. Required fields are marked *