Use includes method with array of arrays - Node.js Array

Node.js examples for Array:Array Operation

Description

Use includes method with array of arrays

Demo Code


var array =[[1,5,6],[2,3],[5,8,9]];
function checkAvailability(arr, val) {
  return arr.some(function(arrVal) {
    return arrVal.includes(val);
  });/*from  w w w.j av  a2 s. co m*/
}
checkAvailability(array, 6); // true
checkAvailability(array, 12) // false

Related Tutorials