check if array contains some array value javascript code example
Example 1: check if array has same values javascript
const allEqual = arr => arr.every(v => v === arr[0]);
allEqual([1,1,1,1]); // true
Example 2: how to check if an array contains a number in javascript
// To check if an array contains a number
const ratings = [1,2,3,4,5];
let result = ratings.includes(4);
console.log(result); // true
result = ratings.includes(6);
console.log(result); // false