Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Check if an array contains a number in javascript

const ratings = [1,2,3,4,5];

let result = ratings.includes(4); 
console.log(result); // true

result = ratings.includes(6); 
console.log(result); // false
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Check #array #number #javascript
ADD COMMENT
Topic
Name
3+6 =