CodeDrill
day_streak: --
← 問題一覧に戻る
JavaScript ・ DOM Manipulation

Problem 65: Adding and Removing a Class

Each time the button #toggleBtn is pressed, add or remove (toggle) the active class on the paragraph #panel. While the active class is applied, the text turns orange.

What you'll train

State the constraints

What you get

  • Specify toggle behavior
  • Clarify the class name
  • Convey the visual condition

How to ask the AI

Clearly tell the AI that each press of the button #toggleBtn should "toggle" the active class on the paragraph #panel—adding it if absent, removing it if present. It also helps to specify explicitly that behavior like classList.toggle is needed.

If you ask vaguelyThe AI sometimes only adds the class and forgets to write the logic for removing it on a subsequent press.

あなたのコード

実行しました

プレビュー

AIレビュー(プロンプト練習)

コードはChatGPTやClaudeに出させたものを貼って構いません。
ここでの本番は「次にAIへ出す指示」です。評価軸は1つだけ見て、弱点・指示の穴・改善例を返します。
テストに落ちていてもレビューできます。落ちた理由と、指示に足りなかった情報を結びつけます。

先にコードを実行し、テストを1つ以上通してください。