scrimba
JS Deep Dive
Hacker News
Hacker News - Building the Favorites Page
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Hacker News - Building the Favorites Page
AboutCommentsNotes
Hacker News - Building the Favorites Page
Expand for more info
router.js
run
preview
console
import Stories from './pages/stories.js';
import Item from './pages/item.js';

const router = new Navigo(null, true, '#');

export default class RouterHandler {
constructor() {
this.createRoutes()
}

createRoutes() {
const routes = [
{ path: '/', page: Stories },
{ path: '/new', page: Stories },
{ path: '/ask', page: Stories },
{ path: '/show', page: Stories },
{ path: '/item', page: Item }
];

routes.forEach(({ path, page }) => {
router.on(path, () => {
page(path);
}).resolve();
})
}
}
Console
›
[]
,
/index.html
-9:20