{"id":"code-hs-js-grade-order-clues","audience":"high-school","category":"coding","track":"coding","technique":"constraints","title":"Get clues for a grade function that gives a C for 95","free":false,"task":"Your JavaScript letterGrade function says 95 is a C. You want to find the bug yourself, so ask for exactly 3 numbered lines labeled 'Clue 1:', 'Clue 2:' and 'Try this:', each under 20 words. 'Try this:' names one score to trace by hand and what the function returns for it now. No code blocks and no fixed code, under 70 words.","materialLabel":"Your function and what it printed (attached to your prompt automatically)","material":"// grades.js - my practice project for Intro to Web Programming\n\nfunction letterGrade(score) {\n  if (score >= 70) {\n    return \"C\";\n  } else if (score >= 80) {\n    return \"B\";\n  } else if (score >= 90) {\n    return \"A\";\n  } else {\n    return \"F\";\n  }\n}\n\nconsole.log(letterGrade(95));   // C   <- should be A\nconsole.log(letterGrade(85));   // C   <- should be B\nconsole.log(letterGrade(72));   // C   <- correct\nconsole.log(letterGrade(40));   // F   <- correct\n\n// My thoughts:\n// - maybe >= is wrong and it should be > ?\n// - I copied the numbers from the syllabus: A 90+, B 80-89, C 70-79, F below 70\n// - the F case works, so the else part is fine I think\n// Ms. Ortiz said \"trace it line by line with one score\" but I don't\n// know which score to pick.","rules":[{"type":"numberedItems","count":3},{"type":"codeBlocks","count":0},{"type":"maxProseWords","max":70}],"mistakes":[{"title":"Getting the fix","why":"The AI's default is a reordered function, which skips the tracing your teacher wants you to do.","fix":"Say: \"No fixed code. Clues only.\"","checks":["r2","codeBlocks"]},{"title":"Chasing the wrong idea","why":"Your note suggests > instead of >=, and the AI may go along with it.","fix":"Ask: \"What does the order of the checks do?\"","checks":["r0","r1"]},{"title":"No score to trace","why":"Without a specific score, 'trace it' is hard to start.","fix":"Add: \"Try this: one score to trace and what it returns now.\"","checks":["r2"]},{"title":"A long explanation","why":"The AI explains if/else from scratch.","fix":"Add: \"Exactly 3 numbered lines, each under 20 words.\"","checks":["numberedItems","maxProseWords"]}],"promptHints":[{"label":"Asks for clues, not the fix","patterns":["clue","don'?t (give|write|show).{0,20}(fix|code|answer)","no (fixed|corrected) code","myself"]},{"label":"Gives the labels","patterns":["clue 1","try this"]},{"label":"Asks for a score to trace","patterns":["score","trace"]},{"label":"Sets the number of lines","patterns":["\\b(3|three)\\b.{0,15}line","numbered"]},{"label":"Caps each line","patterns":["\\d+\\s*words"]}],"hint":"Your teacher wants you to trace it. Ask the AI for clues that point at the problem and a score to trace, not for the answer.","rubricLabels":["Clue 1 says the if/else checks run from top to bottom and the first true one wins","Clue 2 points out that 95 >= 70 is already true, so it returns \"C\" before the >= 90 check is ever reached (the order of the checks)","The lines are labeled Clue 1:, Clue 2: and Try this:, the Try this line names a score and what the function returns for it now (e.g. 85 returns \"C\"), and no fixed code is given"]}