Course · Section 14: Object-Oriented Programming (OOP) With JavaScript · Lecture 226: ES6 Classes
Build a tiny path router. Implement `Router`: - `addRoute(path, handler)` registers a handler name for an exact path. - `resolve(path)` returns the handler name, or `'404'` if the path is not registered.
+ 1 hidden test run on Submit.
An object keyed by path maps to handler names; resolve returns the match or a 404 fallback.
Run your code to see results.