Dynamic Object Keys

Dynamic Keys
πŸ‘¨β€πŸ’Ό We need to model error pages where the property name isn't a valid identifier (like status-404).
When the property name is stored in a variable, you can use a computed property name in an object literal:
const key = 'status-404'
const errorPages = {
	[key]: '/not-found',
}
🐨 Open
index.ts
and:
  1. Create an errorPages object literal that uses the provided key variables (notFoundKey, serverErrorKey) as computed property names
  2. Assign the matching path variables (notFoundPath, serverErrorPath) as values β€” do not hard-code different key strings or paths
  3. Export errorPages
When finished, errorPages should behave like:
  • errorPages['404-status'] === '/not-found'
  • errorPages['500-status'] === '/server-error'

Please set the playground first

Loading "Dynamic Object Keys"
Loading "Dynamic Object Keys"
Login to get access to the exclusive discord channel.
Loading Discord Posts