How to Check if a JavaScript array contains a string​

How to Check if a JavaScript array contains a string​

10 months ago
Anonymous $yw3sRZQrFu

Learn how to use JavaScript array contains methods and techniques to check for different types of elements in arrays.

let colors = ["Red", "Green", "Blue"];

console.log(colors.indexOf("Green")); // Output: 1

console.log(colors.indexOf("White")); // Output: -1

https://www.rajamsr.com/javascript-array-contains/