Created
December 16, 2013 17:46
-
-
Save dejanmarkovic/7991136 to your computer and use it in GitHub Desktop.
find the index of a row by value in 2 dimensional array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function indexOfRowContainingValue(value, arr) { | |
//console.log("value :" + value); | |
//console.log("arr :" + arr); | |
var arrSize = Object.size(arr); | |
//console.log("arrSize :" + arrSize); | |
for (var i=0, arrSize; i<arrSize; i++) { | |
var arrSize2 = Object.size(arr[i]); | |
//console.log("arrSize2 :" + arrSize2); | |
for (var j=0, arrSize2; j<arrSize2; j++) { | |
if (arr[i][j] === value) { return i; } | |
//console.log("arr[i][j] :" + arr[i][j]); | |
} | |
} | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment