Community

Start a Thread


Notifications
Subscribe You’re not receiving notifications from this thread.

Create Browser History (Main Thread)

Here is the interview question prompt, presented for reference.

Every modern browser has implemented a logic for keeping track of the users' browsing history. Usually, it keeps track of the websites visited, and their order, so the user can be able to go back and forth between their recently visited websites.

Can you implement a simplified version of a browser history tracker, that will keep track of the order of visited pages (URLs), and will implement logic for visiting the previous, current and following websites?

It should work like this:

We have an empty browser history []

Then we visit three websites in the following order: First we visit website A, then B, and then C. Then our browsing history would look like this, having website C as the page we are currently visiting: js [ A, B, C] ↑

If we "go back", or call the method back(), our current website would be B, our previous would be A, and the next one will be C.

[ A, B, C]
     ↑          

Thus, by "going forward", or calling the method forward(), we would go to the website C again.

![cover](https://storage.googleapis.com/algodailyrandomassets/curriculum/frontend/interview-questions/create-browser-history.jpg)

You can see the full challenge with visuals at this link.

Challenges • Asked almost 3 years ago by Jake from AlgoDaily

Jake from AlgoDaily Commented on Jun 04, 2022:

This is the main discussion thread generated for Create Browser History (Main Thread).