Array.prototype.includesbeginnerconst colors = ['red', 'green', 'blue']
colors.includes('green') // β true
colors.includes('yellow') // β falseUse includes() for a readable boolean check instead of indexOf() !== -1.
includes() works with any element type. It is the cleanest way to check if a string exists in an array of strings.
Challenge: Implement hasWord(words, word) that returns true if word is in the words array.
hasWord(['hello', 'world'], 'world') // β true
hasWord(['hello', 'world'], 'foo') // β false