Largest Difference in Increasing Indexes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
var largestDifference = function(data) {
// TODO: Program solution
maxDiff = 0;
for ( var i = 0 ; i < data.length; i ++ ){
for ( var j = 0; j < data.length; j ++ ) {
if ( data[i] <= data[j])
maxDiff = Math.max(maxDiff, j - i );
}
}
return maxDiff;
};