Answers for "how to check if an array contains a number in javascript"

15

check if array does not contain value javascript

var fruits = ["Banana", "Orange", "Apple", "Mango"];

var n = fruits.includes("Mango"); // true

var n = fruits.includes("Django"); // false
Posted by: Guest on January-09-2021
0

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
Posted by: Guest on December-27-2020
0

javascript check if array is in array

var array = [1, 3],
    prizes = [[1, 3], [1, 4]],
    includes = prizes.some(a => array.every((v, i) => v === a[i]));

console.log(includes);
Posted by: Guest on June-29-2020

Code answers related to "how to check if an array contains a number in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language