Octagram Labs
JavaScriptData StructuresReact
Sign in
← Back to problems

Reset Form

Events & Formseasy

Course · Section 9: Data Structures, Modern Operators and Strings · Lecture 111: The Spread Operator (...)

Implement `resetForm(form)` returning a new object with every field set to an empty string.

Sample tests

Input: resetForm({"name":"a","email":"b"})
Output: {"name":"","email":""}
Input: resetForm({})
Output: {}

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Mutating the original form.
  • Assuming all values are strings if some are numbers or booleans.

Learning resources

  • React: Reacting to Input with State
Approach & explanation (try first)

Mapping every field to an empty string returns a cleared form object suitable for resetting a controlled form.

Loading...
⌘/Ctrl + Enter

Run your code to see results.