mass2-js Example of how to implement MASS2 in JavaScript https://jsfiddle.net/7uyceo1w/7/ Note that minimum index is shifted by 1. Minimum index - 1 will get you the proper location.