Public demo · Fictional bookmark app

Review results

Validate empty titles first, then deduplicate the sorting logic.

Two changes worth making

01 · Empty titles can be saved

Entering only spaces creates a bookmark with no visible name.

Suggestion: Trim the input, then check for an empty title before saving.

02 · Sorting is duplicated

The saved-bookmarks and search pages each maintain the same time-based sorting code.

Suggestion: Extract a small function and call it from both places.

Example fix

This fictional code illustrates the change. No real project has been modified.

function normalizeTitle(value: string): string {
  const title = value.trim();
  if (!title) throw new Error("Enter a bookmark title");
  return title;
}

Next step

Check how saving behaves with an empty string, spaces only, and a valid title.