xxxxxxxxxx
function checkAllEven(arr) {
return arr.every(function(x){
return x % 2 === 0
})
}
//using "every" to check every item in array.
xxxxxxxxxx
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.includes("Mango");
xxxxxxxxxx
var extensions = ["image/jpeg","image/png","image/gif"];
if(extensions.indexOf("myfiletype") === -1){
alert("Image must be .png, .jpg or .gif");
}
xxxxxxxxxx
const nums = [ 1, 3, 5, 7];
console.log(nums.includes(3));
// true
xxxxxxxxxx
var array = [1, 3],
prizes = [[1, 3], [1, 4]],
includes = prizes.some(a => array.every((v, i) => v === a[i]));
console.log(includes);
xxxxxxxxxx
array.includes('element that need to be checked') //returns true or false
xxxxxxxxxx
console.log(myArray.indexOf('three') > -1);
console.log(myArray.includes('three'));