Array Lookahead
by Beren
HTML
<p id="el">
</p>
JavaScript
var el = document.getElementById('el');
var foo = new Array();
var firstProduct;
var secondProduct = "";
var order;
foo = [
[1, "one2", "one3"],
[2, "two2", "two3"],
[2.1, "two21", "two31"],
[3, "three2", "three3"]
];
for (var i = 0; i < foo.length; i++) {
firstProduct = foo[i][0];
if (foo[i][0] <= foo.length) {
secondProduct = foo[i + 1][0];
if (typeof secondProduct !== 'undefined' && Math.floor(firstProduct) == Math.floor(secondProduct)) {
alert("Match " + firstProduct + " " + secondProduct);
i++;
}
else {
alert("No match - firstProduct" + firstProduct);
}
}
else {
alert("last " + firstProduct);
}
}