JS Coding Questions Logo
JS Coding Questions
#286💼 Interview💻 Code

How do you check whether or not an array includes a particular value

Advertisement

728x90

The Array#includes() method is used to determine whether an array includes a particular value among its entries by returning either true or false. Let's see an example to find an element(numeric and string) within an array.

javascript
1var numericArray = [1, 2, 3, 4];
2
3console.log(numericArray.includes(3)); // true
4
5var stringArray = ["green", "yellow", "blue"];
6
7console.log(stringArray.includes("blue")); //true

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 30

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
286of476
How do you check whether or not an array includes a particular value | JSCodingQuestions.com