Question · Vibe coding with Claude Code course · Module 12: Medium clone

The save date of a draft as a string

Why does the SavedDraft type give the savedAt field the type string and not Date?

Answer options

  • TypeScript has no built-in Date type
  • localStorage stores only numbers, so a date has to be turned into text
  • JSON.stringify turns a date into ISO text, and JSON.parse does not turn it back into a date, so after reading from localStorage the field holds a string anyway
  • A string is shorter than a Date object, so the draft takes less space

You can check the correct answer by solving this task in the CodeWorlds game.