Course · Section 11: Working With Arrays · Lecture 149: Simple Array Methods
Design browser history starting on a homepage. Implement `BrowserHistory`: - `new BrowserHistory(homepage)`. - `visit(url)` goes to url from the current page, clearing any forward history. - `back(steps)` moves back up to steps pages and returns the current url. - `forward(steps)` moves forward up to steps pages and returns the current url. - `current()` returns the current url.
+ 1 hidden test run on Submit.
An array of visited pages with a current-position index supports back/forward by clamping the index; visiting truncates the forward portion. O(1) per navigation (visit is O(n) due to the truncation).
Run your code to see results.