I have some browser history input, for example let's assume this is what the history looks like when clicked
http://example.com/index.php
http://example.com/profile.php
http://example.com/comments.php
http://example.com/contact.php
Now the difference between the index page and the contact page is 3, how can I calculate it
var currentPage = "index.php";
var historyPage = "contact.php";
var pageDiff = // historyPage - currentPage
If you want to know the distance between two items in an array, you can use
indexOf. I'm assuming your browser history is in an array, and not just one big text blob.Something like: