Use the includes() method on the array instance.

For example:

['red', 'green'].includes('red') //true ✅

['red', 'green'].includes('yellow') //false ❌

Download my free JavaScript Beginner's Handbook!


Check out my in-depth, practical Web Development Courses!

(all 50% off with the coupon code POSITIVEVIBRATIONS)

⤴️⤴️⤴️

And signup to my upcoming JavaScript Bootcamp!

⤴️⤴️⤴️