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

Problem 67: Display the Sum of Two Numbers

When numbers are entered into the two input fields #numA and #numB and the button #calcBtn is pressed, make it so that the sum of the two numbers is displayed in the paragraph #sum.

Hint: Since the values from the input fields are strings, simply using + directly will concatenate them, resulting in something like "34".

What you'll train

State the constraints

What you get

  • Specify the type conversion
  • Clarify the calculation method
  • Confirm the input format

How to ask the AI

Clearly tell the AI that the values of #numA and #numB are retrieved as strings, so they need to be converted to numbers before being added together. It also helps to specify how to handle blank fields or non-numeric input.

If you ask vaguelyThe AI may forget the type conversion, resulting in "3" and "4" being displayed concatenated as "34" instead of being added.

あなたのコード

実行しました

プレビュー

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

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

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