Skip to content

Instantly share code, notes, and snippets.

@mishrsud
Created December 21, 2017 20:07
Show Gist options
  • Save mishrsud/8e85f064509b22d79360ea9ca6989f64 to your computer and use it in GitHub Desktop.
Save mishrsud/8e85f064509b22d79360ea9ca6989f64 to your computer and use it in GitHub Desktop.
JavaScript array of arrays
function arrayTest() {
var array = [
[1234, "123123-132131-ejwh213", "comment 1234 | comment 2345"],
[1235, "123124-132132-ejwh214", "comment 3 | comment 32"],
[1236, "1231235132133-ejwh215", "comment 4 | comment 5"]];
var theArray = array.find(function (el) {
return el.indexOf("1231235132133-ejwh215") > -1;
});
var comments = theArray[2].split('|');
console.log(theArray);
console.log(comments);
comments.forEach(function (element) {
if (element.indexOf("4") > 0) {
console.log("found " + element);
}
});
}
arrayTest();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment