JS Built-ins
Modulesadvanced

Tree Shaking Friendly Exports

Tree shaking removes unused exports from the bundle. Named exports are tree-shakeable; a default export of an object is not (bundler can't tell which properties are used). Prefer export const foo = ... over export default { foo, bar } for better tree shaking.

πŸ’‘ Hints (5)
  • β€’ Return an object with formatDate and formatCurrency properties
  • β€’ formatDate should accept a Date and return the ISO date string (YYYY-MM-DD)
  • β€’ Use d.toISOString().split('T')[0] to extract the date part
  • β€’ formatCurrency should accept a number and return formatted string with $
  • β€’ Use n.toFixed(2) to format the currency to 2 decimal places