[
  {
    "id": "filter",
    "title": "Who disappears from the results?",
    "concept": "Filtering",
    "prompt": "Keep scores of 50 or above. Does the proposed code follow that rule?",
    "code": "const scores = [0, 49, 50, 80];\nconst kept = scores.filter((score) => score > 50);",
    "corrected": "const scores = [0, 49, 50, 80];\nconst kept = scores.filter((score) => score >= 50);",
    "options": [
      "[80]",
      "[50, 80]",
      "[0, 49, 50, 80]"
    ],
    "answer": 0,
    "expected": "[50, 80]",
    "actual": "[80]",
    "hint": "Compare \u201cabove 50\u201d with \u201c50 or above\u201d. Test the boundary value 50.",
    "explanation": "The condition > 50 removes the score 50. The requested rule is >= 50. A plausible one-character choice changes who is included.",
    "counterexample": "With [60, 80], both versions return [60, 80]. Typical examples alone would miss this bug.",
    "testInput": [
      0,
      49,
      50,
      80
    ],
    "testKind": "filter",
    "rule": "score >= 50"
  },
  {
    "id": "sort",
    "title": "Does the order mean what you think?",
    "concept": "Sorting",
    "prompt": "Order numeric scores from lowest to highest. Does sort() alone do this?",
    "code": "const scores = [3, 20, 100];\nconst ordered = [...scores].sort();",
    "corrected": "const scores = [3, 20, 100];\nconst ordered = [...scores].sort((a, b) => a - b);",
    "options": [
      "[3, 20, 100]",
      "[100, 20, 3]",
      "[20, 3, 100]"
    ],
    "answer": 1,
    "expected": "[3, 20, 100]",
    "actual": "[100, 20, 3]",
    "hint": "Without a compare function, sort() compares string forms. What comes first: \u201c100\u201d or \u201c3\u201d?",
    "explanation": "The default ordering compares string forms rather than numeric size. A numeric comparator makes the intended rule explicit. The spread copy keeps the input array unchanged.",
    "counterexample": "With [1, 2, 3], both versions look correct. Include multi-digit numbers to test the claim.",
    "testInput": [
      3,
      20,
      100
    ],
    "testKind": "sort",
    "rule": "numeric ascending"
  },
  {
    "id": "missing",
    "title": "Missing is not the same as zero",
    "concept": "Missing data",
    "prompt": "Keep every recorded numeric score, including 0. Does filter(Boolean) preserve them?",
    "code": "const scores = [0, null, 50, 80];\nconst recorded = scores.filter(Boolean);",
    "corrected": "const scores = [0, null, 50, 80];\nconst recorded = scores.filter((score) =>\n  typeof score === \"number\" && Number.isFinite(score)\n);",
    "options": [
      "[0, 50, 80]",
      "[null, 50, 80]",
      "[50, 80]"
    ],
    "answer": 2,
    "expected": "[0, 50, 80]",
    "actual": "[50, 80]",
    "hint": "Boolean(0) is false. Is a recorded zero an absent value?",
    "explanation": "filter(Boolean) removes every falsy value, including zero. The revised rule keeps finite numbers and excludes null, missing values and numeric-looking strings. This is a documented choice, not a universal cleaning rule.",
    "counterexample": "If zero is explicitly defined as a missing-value code in another dataset, a different cleaning rule may be justified. Inspect the data dictionary first.",
    "testInput": [
      0,
      null,
      50,
      80
    ],
    "testKind": "missing",
    "rule": "finite numbers, including zero"
  }
]