If you need to check if array contains element, the best way will be with
includes method that exists on array prototype.
This method was added in ES6, but if you still have to write in older version
indexOf method and check if it returns valid
index. If you aren't version constrained there is no reason to use it for
this purpose. ES6 way is much more readable.