I cannot figure out why I keep getting -1 for lastProductIndex when clearly the lastProductID is in the array!
var lastProductID = 6758;
var allProductIDs =
Are you using any other JavaScript libraries in your page?
There could be a conflict for the $ shorthand if you are. This can be solved in a number of ways, one of which would be wrapping the code in a self-executing anonymous function
(function($) {
var lastProductIndex = $.inArray(lastProductID, allProductIDs);
})(jQuery);